Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,114 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,766 people online right now. Registration is fast and FREE... Join Now!




How to return the file path of a saved file

 
Reply to this topicStart new topic

How to return the file path of a saved file

elodie
12 Apr, 2007 - 06:39 AM
Post #1

New D.I.C Head
*

Joined: 12 Apr, 2007
Posts: 1


My Contributions
Hi,

I have a form that encodes and decodes a file.
When the user selects the encode button, the user selects a file to open and that file is encoded and saved as a different file.

I now need the decode function to work. When the user selects the decode button, i want it to automatically start to decode the saved encoded file. so i would like to be able to hard code the file path of the saved file into this option. I'm struggling here because i'm not sure how to get the file path of a file.

Can anybody help?

My code is below:

CODE


if (OpenFileDialog->Execute())
     input = OpenFileDialog->FileName.c_str();

    if (SaveFileDialog->Execute())
     output = SaveFileDialog->FileName.c_str();

    std::ifstream infile(input.c_str(), std::ios::in | std::ios::binary);

    if (output.find(".drc") == -1)
     output = output + ".drc";
    std::ofstream outfile(output.c_str(),std::ios::out | std::ios::binary);



I would like to be able to find the complete path of output in order to hard code it in the decoder method. Can anybody help?

Cheers
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: How To Return The File Path Of A Saved File
12 Apr, 2007 - 07:46 AM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
Well... if the full path information is FileName then you could extract it. If the file name is just the name of the file, then the directory is whatever ".\" is...

If I am thinking correctly, the windows API has functions to extract directory information... I don't have time to look that up at the moment, but some of the things you want to look into are GetFullPathName, GetFileInformationByHandle, GetCurrentDirectory.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:49PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month