# Reset directory

## Recommended Posts

MetaCipher    145
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 on other sites
Drew_Benton    1861
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 on other sites
MetaCipher    145
It seems that those two functions were just what I was looking for, thanks! I got my app working now.