Quick Question: How can I make sure the current directory is not changed because of OpenFileDialog?

Posted by pecker on Stack Overflow See other posts from Stack Overflow or by pecker
Published on 2010-05-04T02:18:58Z Indexed on 2010/05/04 2:28 UTC
Read the original article Hit count: 296

Filed under:
|

say my application is installed in C:\programfiles\xyz\ I've some setting & other data files (*.dat files) in this directory too.

My application uses OpenFileDialog to open an image. Problem is that when ever user browses to some directory (say MyPictures) for an image. The current working directory of the application becomes that directory (MyPictures in this case).

After user inputs the image. I do some processing over it and save some values to imagedata.dat which will be located in the path where original application is installed.(C:\programfiles\xyz here )

In my code I'm just using FileStream("imagedata.dat",...,...) without any path prefix before the filename. Problem here is that application is crashing because it is searching for imagedata.dat in 'MyPictures\imagedata.dat'.

How can I avoid this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET