C#設(shè)置文件權(quán)限

   在開發(fā)中,我們經(jīng)常會(huì)使用IO操作,例如創(chuàng)建,刪除文件等操作。在項(xiàng)目中這樣的需求也較多,我們也會(huì)經(jīng)常對(duì)這些操作進(jìn)行編碼,但是對(duì)文件的權(quán)限進(jìn)行設(shè)置,這樣的操作可能會(huì)手動(dòng)操作,現(xiàn)在介紹一種采用代碼動(dòng)態(tài)對(duì)文件設(shè)置權(quán)限的操作。

   在對(duì)文件進(jìn)行權(quán)限設(shè)置在DOtNet中,會(huì)采用FileSystemAccessRule類進(jìn)行文件的權(quán)限操作。

    1.現(xiàn)在看一下FileSystemAccessRule的實(shí)現(xiàn)代碼:

復(fù)制代碼
  public FileSystemAccessRule(
            IdentityReference identity,
            FileSystemRights fileSystemRights,
            AccessControlType type )
            : this( identity,
                AccessMaskFromRights( fileSystemRights, type ),
                false,
                InheritanceFlags.None,
                PropagationFlags.None,
                type )
        {
        } public FileSystemAccessRule(
            String identity,
            FileSystemRights fileSystemRights,
            AccessControlType type )
            : this(
                new NTAccount(
        		

延伸閱讀

學(xué)習(xí)是年輕人改變自己的最好方式-Java培訓(xùn),做最負(fù)責(zé)任的教育,學(xué)習(xí)改變命運(yùn),軟件學(xué)習(xí),再就業(yè),大學(xué)生如何就業(yè),幫大學(xué)生找到好工作,lphotoshop培訓(xùn),電腦培訓(xùn),電腦維修培訓(xùn),移動(dòng)軟件開發(fā)培訓(xùn),網(wǎng)站設(shè)計(jì)培訓(xùn),網(wǎng)站建設(shè)培訓(xùn)學(xué)習(xí)是年輕人改變自己的最好方式