UnauthorizedAccessException when reading from Application Directory
I am trying to read translation files from the application directory, but the call to open a Stream fails:
fstream = new FileStream(path, FileMode.Open);
开发者_如何学编程
I don't quite understand why, as the user persmissions for the file are present.
Does anybody know a way to overcome this?
many thanks in advance,
Philip
EDIT:
I finally found the answer myself. The FileStream accepts another parameter which defnies the file access (FileAccess.Read in this case):
fstream = new FileStream(path, FileMode.Open, FileAccess.Read);
With this modification it works just fine.
精彩评论