tags:

views:

259

answers:

1

I'm using boost to create a directory to place some temp files in.

int main( int argc, char* argv[] )
{
    std::cout << "Current Dir: " << argv[0] << std::endl;
    boost::filesystem::create_directories( "TempFolder" );
    return 0;
}

Now if double click the exe, the folder "TempFolder" is created in the same directory as the exe, which I expect. However if I now drag a file onto the exe the folder is created in "C:\Documents and Settings\0xC0DEFACE" which i certainly was not expecting.

Seeing my app hasnt changed, and the dir being printed out hasnt changed, and my app is currently ignoring passed strings, why is the folder now being created in a new directory?

im running windows XP, with VS9 and am using boost 1.39.

+1  A: 

I think it's because of the way you 'execute' your binary.

In the first case you double click it and it will run in 'current' directory.

In the second case you drop file on it which causes different action by Windows to execute your binary. In the second case the binary runs in your 'home' directory I believe.

It's the difference between how Windows executes your application.

I've had similar issues when dropping files on my executable.

stefanB
Btw you can confirm that it's executed in different directory by opening a file in current directory, if you don't specify full path, I bet the application will not be able to find local file if you execute binary by dropping some other file on it because it will start in your home directory instead of your current directory.
stefanB