tags:

views:

46

answers:

2

So I'm using a SaveFileDialog to save a file to a location the user selects. After the saving has occurred, the user is able to do what they want with the file and folder they saved to.

However, the user cannot delete or modify the folder...it's being held in memory by the application so when another SaveFileDialog is opened, it can point to that same directory.

Our application is fairly complex and I don't want this sort of feature enabled. Is there a way to turn it off?

Thank you in advance.

A: 

Make sure you're disposing the stream or whatever resource you're using to actually write the file. This resource is most likely staying open locking the folder and file. Read about the using() syntax here http://msdn.microsoft.com/en-us/library/yh598w02(VS.80).aspx.

Jimmy Hoffa
+3  A: 

Short from mis-behaving shell extensions, this is normal. SFD will change the current working directory of your program to the directory that contains the file selected by the user. And that puts a lock on the directory.

You avoid this by setting the RestoreDirectory property to True.

Hans Passant