What’s happening to me is, when I run my program out of Visual studio, it can’t use relative paths to find anything.
This is proving difficult to articulate…
Like, I’ve got program X, which opens textfile.txt, right? And if I point to textfile.txt with an absolute path, I’m fine. And if I point to it with a relative path and I compile program X, then run it directly (ie, by double-clicking programX.exe in the debug folder), I’m also fine. But, if I use a relative path and run the program out of visual studio (ie, by pressing f5), then it can’t find the file.
Anyone know what’s happening? Alternatively, can anyone suggest some decent keywords that don’t collide squarely with other newbie Visual Studio issues?
Ben
Not sure about VS2008 but earlier version ran the program with a current directory of debug (or release, I guess) underneath your project directory. You may have to make sure you use that as the root of your path.
Alternatively, prepend your relative path with ‘..\’.
Temporarily put a
system('cd');inside your code to find out where it’s actually running from or useGetCurrentDirectory(...)as suggested by Nick.