Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Relative filenames

Status
Not open for further replies.

PlasmaZero

Programmer
Dec 6, 2002
13
0
0
US
In my prog, it is set up so that the user can load a file of their choice and also load a permanent .txt file that is in the same directory as the program. If I load the .txt file first, it works fine. But, if I load a file that is not in the same directory as the program and then try to load the .txt file, it is not found.
Is there a way to reset the file path so that it will always search for the .txt file in the directory of the program?
Thanks
 
Looks like you change to the source-drive/directory before
reading the file.
Need not do this. Use the file's path with the open-statement, thus your working directory will always be where
your program is.
If you change to another location, you first have to read
and save the current directory (with GetCurrentDir or something like that), then you always can change back.
But I'd prefer the first method.
Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top