I want to copy an encrypted file which is being used by another process.
This works:
System.IO.File.Copy("path1", "path2",true);
but the below code is not working. Prompts "file access denied" error:
using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))//access denied open file
{
using (Stream copyFileStream = new StreamDecryption(new FileStream(copyTo, FileMode.Create)))
{
}
}
How can i copy an encrypted file if file is used by another process?
Thanks
Update:i used this code and worked for me:
using (var fileStream = new System.IO.FileStream(@"filepath", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite))
{
}