Frage

I'm using StreamReader class to read a file but getting Unauthorized access exception in doing so. I can manually open the file and read it. Does the program run with less permission than what my user account has? I'm creating a C# console application with VS 2010. My user account doesn't have administrator rights but enough for me to read and write to the folder containing this file. Also, the file I'm trying to read was generated by another user but my account has Read & Execute and Read permissions for it.

War es hilfreich?

Lösung

Shortly after posting this I realized I was opening the file with read/write access instead of readonly access. I modified my code to do File.OpenRead instead of File.Open and now it works

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top