Checking file/folder access permission

前端 未结 3 1224
故里飘歌
故里飘歌 2020-11-27 22:15

I get an UnautorizedAccessException running this code:

string[] fileList = Directory.GetFiles(strDir, strExt);

The exception o

3条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 22:59

    Check article on code project which is about the thing you need, the is class created for this : The purpose of this class is to provide a simple answer to a common question, "Do I have permission to Read or Write this file?".

    A simple way to test individual access rights for a given file and user

    Note: cannot post whole code over here because its too long.

提交回复
热议问题