'How to fix the "Access to the Path Denied" issue on C# Winform?
I have made a program to modify a file, it works well when I run it regularly:
string modifiedFile = tmpPath + "\\Ext\\out.dat";
FileStream writeStream = File.OpenWrite(modifiedFile);
byte[] newData = new byte[2];
newData[0] = 0x4B;
newData[1] = 0x4B;
writeStream.Seek(0, SeekOrigin.Begin);
writeStream.Write(newData, 0, newData.Length);
writeStream.Close();
But if I run it from the Email client, which has an email with the attached file, when I click on the attached file (the format has associated to the program), the program runs but throws an error:
Access to the path 'C:\Users\admin\AppData\Local\Temp\Ext\out.dat' is denied
I checked the folder "C:\Users\admin\AppData\Local\Temp\Ext" and the out.dat file is there. What should I do to resolve this? It seems the system doesn't allow me to modify the file?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
