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.
I know it is not possible to point OpenFileDialog()
to some other folder from code. Any pointers?
Btw, this is the windows error message:
The action can't be completed because the folder is open in another program. Close the folder and try again.
I had the same problem. The follow fixed it
Stream fileStream = openFileDialog1.OpenFile();
if (fileStream != null)
{
...
fileStream.Close();
}
By closing the stream my problem went away... :P
using(var fileStream = openFileDialog1.OpenFile())
{
// do your stuff
}
this will close the stream and fix your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With