вторник, 7 сентября 2010 г.
WPF OpenFileDialog() locks the folder
I use OpenFileDialog() in my Silverlight application. When I select a file using ShowDialog() it simply locks the file until I close my application.
I am not able to rename or delete the folder when the application is running (silverlight application in browser)
If I try to select any other file in any another folder, I am able to rename the previous folder. It seems it is releasing the handle.
My goal: I want to rename/delete the folder in filesystem (manually) once I finished uploading.
By default the dialog changes the process' current directory (as in System.Environment.CurrentDirectory) to the one the selected file is in. This is so it can default to the same directory again if you open the dialog a second time.It's not the dialog itself that keeps the directory "locked", it's the fact that it's the current directory for the process. Anyway, you can suppress this behavior by setting the dialog's RestoreDirectory property to true.