开发者

UnauthorizedAccessException when reading from Application Directory

开发者 https://www.devze.com 2023-03-11 18:54 出处:网络
I am trying to read translation files from the application directory, but the call to open a Stream fails:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消