Pregunta

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.

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top