Sign in to follow this  
Wavewash

Making file paths local

Recommended Posts

Wavewash    202
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
MauMan    344
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
Fruny    1658
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this