-
change active directory
Hi....
Assume I have this directory: /opt/blabla
Inside it there are: bla ( executable file ) and resource.txt ( resource file needed by bla )
$ cd /opt/blabla
$ ./bla
Everything runs fine...
$ cd ~/
$ /opt/blabla/bla
Error: cann't find resource.txt
or
$ ln -s /opt/blabla/bla /usr/bin/bla
$ cd ~/
$ bla
Error: cann't find resource.txt
Is there anyway to set the current ( working ) directory to where the binary live????? I mean in bla code anyway..... So, this is part of bla source code:
Code:
String file = "resource.txt";
//how to set the working directory to where the binary live.....
LoadTheFile( file );
Hardcode path is not an option....
Thank you....
-
You can use chdir() to change directories. If you don't want to hardcode in the directory, you can have it take it in as an command line argument.
-
-