MADMAN69UK
Member
- Joined
- Jun 23, 2004
- Messages
- 6
- Programming Experience
- Beginner
Hey there.
I have written a small program just to test a few bits of code out before I insert it into a larger program. Everythings works other than a little problem when opening a file.
Basically, the program is supposed to change the location of a .txt file. If I leave the .txt file in the BIN directory and run the prog and select the file, it opens it fine. If however I copy the same .txt file to C:\ for example, then try to open it I get the 'File Not Found!' message which I entered into the program for errors.
Does anyone have any idea what I can do to prevent this? I assume it's something to do with the openfiledialog but I'm not really sure.
Cheers.
-----Edit-----
After further testing, if I copy the compiled .exe and the .txt file to C:\ and run the program then it works fine. It seems to only work when the .txt file is still in the same folder as the .exe file. Is there some code like '%App Path%/Data.txt' or something to that effect which I have to use? Like with DOS when you'd use '%SystemRoot%'.
I have written a small program just to test a few bits of code out before I insert it into a larger program. Everythings works other than a little problem when opening a file.
Basically, the program is supposed to change the location of a .txt file. If I leave the .txt file in the BIN directory and run the prog and select the file, it opens it fine. If however I copy the same .txt file to C:\ for example, then try to open it I get the 'File Not Found!' message which I entered into the program for errors.
Does anyone have any idea what I can do to prevent this? I assume it's something to do with the openfiledialog but I'm not really sure.
Cheers.
-----Edit-----
After further testing, if I copy the compiled .exe and the .txt file to C:\ and run the program then it works fine. It seems to only work when the .txt file is still in the same folder as the .exe file. Is there some code like '%App Path%/Data.txt' or something to that effect which I have to use? Like with DOS when you'd use '%SystemRoot%'.
Last edited: