-
File reading in folders
Right now I can open any text file or whatnot but it needs to be in the same folder as the exe. How do I tell the program not to look there but to look in a folder called maps? I am using MSVC++
I would like to do this with using just the fstream operators and such if possible.
the folder maps in in the same folder as the exe
-
if you know if the folder is on a certain drive, you could try opening it with ifstream. i.e.
Code:
ifstream infile("c:\maps\textfile.txt");
if you created the folder with your program, you should be able to open a file from that folder. the tricky part is making sure the harddrive is designated with the c: letter. i'm sorry, i can't help you there, but i'm sure there are others that can. hope this helps some.
-
Yea this helps alot ... I wasnt sure of the syntax of just reading from a folder much less on what drive its on... I may be able to not specify and hope it reads from the same directory that the exe is in.
-
AHH I found it I am using MFC and It just so happens that there is a string that is defined when you make a new project called THIS_FILE When I couted the character array it gave me the full directory that the game is in so if i just add \maps to the end of that it will bring my map files into scope. thanks for the help
Alas it only gives the directory of the .cpp file no matter what machine I run it on =/
-
you're welcome. thanks for the info. good thing to know.