Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bishop_pass

Why is working dir still Release/ even after moving .exe somewher else?

This topic is 5720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I don''t recall ever having this problem before. I built my Visual C++ 6.0 project in Release mode. It runs fine. I copied it and its files to another directory as if it was being installed somewhere else. I run it from that location. Why the heck is it still accessing files in the Release/ directory? All my file opens, etc. are in relative mode. I do not hardcode my directories. Why does the program access the files in the Release/ directory? This program no longer has anything to do with that directory. Does Visual C hardcode that into my app? I don''t recall it doing something like this before. Did I forget to toggle something in my build?

Share this post


Link to post
Share on other sites
Advertisement
Try to get the path of the current working directory when you startup your app. Paste this path before your file names and you should be fine. I had the same trouble with my ini files and i fixed it this way.

Share this post


Link to post
Share on other sites
The working directory is whatever directory you are in when the application is launched.

Are you running from the IDE? You can set the working directory in the environment settings.

- Magmai Kai Holmlor

"Oh, like you''ve never written buggy code" - Lee

[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ]

[Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ | wxWindows| Spirit(xBNF)]
[Free C Libraries | zlib ]

Share this post


Link to post
Share on other sites
quote:
Original post by Magmai Kai Holmlor
The working directory is whatever directory you are in when the application is launched.

Yeah.

Then why is my program accessing and modifying the files in the Relase/ directory even though I''ve copied it elsewhere?

Share this post


Link to post
Share on other sites
Actually, it appears that the program is accessing files in the C:\WINNT directory as well (or instead), whatever.

I called GetCurrentDirectory() and _getcwd() and both return C:\WINNT.

This is no good. My program is trying to load a file from the same directory that the program was launched from. Since my program can''t know where it is installed, how do I find the directory of where the program resides?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
just curious, are you using the privateprofile... api functions to access these files? and what OS are you using?

Share this post


Link to post
Share on other sites
I don''t know anything about privateprofile and whether I''m inadverdently using it or not.

I''m building on Win2k with MSVC 6. I want the program to work on 95/98/2k/xp. It''s a pretty simple app.

Share this post


Link to post
Share on other sites
Use GetModuleFileName() with hModule set to NULL to retrieve the directory in which the executable resides.

RapscallionGL - arriving soon.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!