Currently developing a C# WinForms application in Visual Studio 2010 .NET 4 on Windows 7.
Firstly I am reading a stream of bytes from a file using the File.ReadAllBytes() method. Then when attempting to write the file back, I am getting a access to path denied error when using the WriteAllBytes method.
I have tried passing in literal paths, Environment.SpecialFolder.ApplicationData, Path.GetTempPath(), but all are providing me with the same error.
I have checked permissions on these folders and also attempted to start the program in administrator mode with no luck.
You may see “Access to the path is denied” error if the application is not able access to a path that is trying to read or write. This will show up as 401 Unauthorized error in IIS logs.
Make sure that you specify the entire path when using File.WriteAllBytes()
including file name.
File.WriteAllBytes()
cannot write to a general directory, it has to write to a specific file.
Hope this helps.
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