Jump to content
  • Advertisement
Sign in to follow this  

Reset directory

This topic is 4802 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 open a file using OPENFILENAME. Then later on when I save a file using SDL_SaveBMP(), it saves to directory from OPENFILENAME. How do I reset it back to the directory to where the program is being ran?

Share this post


Link to post
Share on other sites
Advertisement
Taken from MSDN:

#include <direct.h>
#include <stdlib.h>
#include <stdio.h>

char g_buffer[_MAX_PATH];

int main( int argc, char* argv[] )
{
/* Get the current working directory: */
_getcwd( g_buffer, _MAX_PATH )

.. Init SDL and Stuff
.. OPENFILENAME call ...

_chdir(g_buffer);
SDL_SaveBMP();
}






Give that a try. It is what I had to do when working with Win32 and saving/opening files in a similar way. I used _getcwd rather than argv[0] because if you need it for a Win32 App, it will still be the same. [smile]

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!