Sign in to follow this  

Making file paths local

This topic is 4677 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'm using GetOpenFileName to get the path of a filename that I want to store. The path looks something like: C:\windows\desktop\gizmo\script\script.mts My executable is sitting in C:\windows\desktop\gizmo Is there any easy way to get the local filepath and remove that from the full filepath of the files? I'm lost as to how to find my local filepath. Thanks. ~Wave

Share this post


Link to post
Share on other sites
Assumming C/C++) To get the directory your program is currently executing (which may not be the directory where your program is located) call getcwd(). For the fully qualified path to your program (including the program name) look at the first argument passed to the program (e.g. if you have main( int argc, char** argv ) then look at argv[0] ).

Share this post


Link to post
Share on other sites
Quote:
Original post by MauMan
For the fully qualified path to your program (including the program name) look at the first argument passed to the program (e.g. if you have main( int argc, char** argv ) then look at argv[0] ).


That depends on the platform and on how the program has been started. If you just type the name of the program on a command line (as opposed to starting it from a GUI), you're likely to just end up with the program's name in argv[0], not the full path. The CWD may also be different when starting from a GUI (it's an option in the application/shortcut properties on Windows, I believe).

Share this post


Link to post
Share on other sites
Sign in to follow this