FileStream to save file then immediately unlock in .NET ?
Posted
by aron
on Stack Overflow
See other posts from Stack Overflow
or by aron
Published on 2010-04-19T20:00:21Z
Indexed on
2010/04/19
20:23 UTC
Read the original article
Hit count: 234
I have this code that saves a pdf file.
FileStream fs = new FileStream(SaveLocation, FileMode.Create);
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
fs.Flush();
fs.Close();
It works fine. However sometimes it does not release the lock right away and that causes file locking exceptions with functions run after this one run.
Is there a ideal way to release the file lock right after the fs.Close()
© Stack Overflow or respective owner