FileSystemRights 列挙体とは? わかりやすく解説

FileSystemRights 列挙体

メモ : この列挙体は、.NET Framework version 2.0 で新しく追加されたものです。

アクセス規則と監査規則の作成時に使用するアクセス権を定義します。

この列挙体には、メンバ値のビットごとの組み合わせを可能にする FlagsAttribute 属性が含まれています。

名前空間: System.Security.AccessControl
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<FlagsAttribute> _
Public Enumeration FileSystemRights
Dim instance As FileSystemRights
[FlagsAttribute] 
public enum FileSystemRights
[FlagsAttribute] 
public enum class FileSystemRights
/** @attribute FlagsAttribute() */ 
public enum FileSystemRights
FlagsAttribute 
public enum FileSystemRights
メンバメンバ
 メンバ名説明
AppendDataファイルの末尾にデータを追加する権限を指定します。 
ChangePermissionsファイルまたはフォルダに関連付けられたセキュリティ規則と監査規則を変更する権限を指定します。 
CreateDirectoriesフォルダを作成する権限を指定します。  

この権限には Synchronize 値が必要です。ファイルまたはフォルダの作成時に Synchronize 値を明示的に設定しない場合、Synchronize 値は自動的に設定されます。

CreateFilesファイルを作成する権限を指定します。  

この権限には Synchronize 値が必要です。ファイルまたはフォルダの作成時に Synchronize 値を明示的に設定しない場合、Synchronize 値は自動的に設定されます。

Deleteフォルダまたはファイルを削除する権限を指定します。  
DeleteSubdirectoriesAndFilesフォルダおよびそのフォルダ内に格納されているファイルを削除する権限を指定します。 
ExecuteFileアプリケーション ファイルを実行する権限を指定します。 
FullControlフォルダまたはファイルに対してフル コントロールを行い、アクセス制御と監査規則を変更する権限を指定します。この値は、ファイルに対してどのような操作でも行うことができる権限を表します。この値は、この列挙体のすべての権限を組み合わせたものです。 
ListDirectoryディレクトリの内容を読み取る権限を指定します。 
Modify読み取り、書き込み、フォルダの内容の一覧表示、フォルダとファイルの削除、およびアプリケーション ファイルの実行を行う権限を指定します。この権限には、ReadAndExecute 権限、Write 権限、および Delete 権限が含まれます。 
Readフォルダまたはファイルを読み取り専用として開いたり、コピーしたりする権限を指定します。この権限には、ReadData 権限、ReadExtendedAttributes 権限、ReadAttributes 権限、および ReadPermissions 権限が含まれます。 
ReadAndExecuteフォルダまたはファイルを読み取り専用として開いたりコピーしたりする権限、およびアプリケーション ファイルを実行する権限を指定します。この権限には、Read 権限および ExecuteFile 権限が含まれます。 
ReadAttributesフォルダまたはファイルのファイル システム属性を開いたり、コピーしたりする権限を指定します。たとえば、この値は、ファイルの作成日や変更日を表示する権限を指定します。これには、データ、拡張ファイル システム属性、またはアクセス規則や監査規則を読み取る権限は含まれません。 
ReadDataファイルまたはフォルダを開いたり、コピーしたりする権限を指定します。これには、ファイル システム属性、拡張ファイル システム属性、またはアクセス規則や監査規則を読み取る権限は含まれません。 
ReadExtendedAttributesフォルダまたはファイルの拡張ファイル システム属性を開いたり、コピーしたりする権限を指定します。たとえば、この値は、作成者や内容に関する情報を表示する権限を指定します。これには、データ、ファイル システム属性、またはアクセス規則や監査規則を読み取る権限は含まれません。 
ReadPermissionsフォルダまたはファイルのアクセス規則や監査規則を開いたり、コピーしたりする権限を指定します。これには、データ、ファイル システム属性、および拡張ファイル システム属性を読み取る権限は含まれません。  
Synchronizeファイル ハンドルが I/O 操作の完了に同期するまでアプリケーションが待機できるかどうかを指定します。 

Synchronize 値は、アクセスを許可すると自動的に設定され、アクセスを拒否すると自動的に除外されます。

ファイルまたはフォルダを作成する権限には、この値が必要です。この値は、ファイルの作成時に明示的に設定しなくても、自動的に設定されます。

TakeOwnershipフォルダまたはファイルの所有者を変更する権限を指定します。リソースの所有者は、そのリソースに対してフル アクセス権限を持ちます。 
Traverseフォルダの内容を一覧表示し、そのフォルダに格納されているアプリケーションを実行する権限を指定します。 
Writeフォルダおよびファイルを作成し、ファイルに対してデータの追加または削除を行う権限を指定します。この権限には、WriteData 権限、AppendData 権限、WriteExtendedAttributes 権限、および WriteAttributes 権限が含まれます。  
WriteAttributesフォルダまたはファイルのファイル システム属性を開いたり、フォルダまたはファイルにファイル システム属性を書き込んだりする権限を指定します。これには、データ、拡張属性、またはアクセス規則や監査規則を書き込む権限は含まれません。 
WriteDataファイルまたはフォルダを開いたり、ファイルまたはフォルダに書き込んだりする権限を指定します。これには、ファイル システム属性、拡張ファイル システム属性、またはアクセス規則や監査規則を開いたり書き込んだりする権限は含まれません。 
WriteExtendedAttributesフォルダまたはファイルの拡張ファイル システム属性を開いたり、フォルダまたはファイルに拡張ファイル システム属性を書き込んだりする権限を指定します。これには、データ、属性、またはアクセス規則や監査規則を書き込む権限は含まれません。 
解説解説
使用例使用例

FileSystemRights 列挙体を使用して、ファイルにアクセス規則を指定し、次にそのアクセス規則を削除するコード例を次に示します。この例を実行するには、有効なユーザーまたはグループ アカウントを指定する必要があります。

Imports System
Imports System.IO
Imports System.Security.AccessControl



Module FileExample

    Sub Main()
        Try
            Dim fileName As String
 = "test.xml"

            Console.WriteLine("Adding access control entry for
 " & fileName)

            ' Add the access control entry to the file.
            AddFileSecurity(fileName, "DomainName\AccountName",
 _
                FileSystemRights.ReadData, AccessControlType.Allow)

            Console.WriteLine("Removing access control entry from
 " & fileName)

            ' Remove the access control entry from the file.
            RemoveFileSecurity(fileName, "DomainName\AccountName",
 _
                FileSystemRights.ReadData, AccessControlType.Allow)

            Console.WriteLine("Done.")
        Catch e As Exception
            Console.WriteLine(e)
        End Try

    End Sub


    ' Adds an ACL entry on the specified file for the specified account.
    Sub AddFileSecurity(ByVal fileName As
 String, ByVal account As
 String, _
        ByVal rights As FileSystemRights, ByVal
 controlType As AccessControlType)
  
        ' Get a FileSecurity object that represents the 
        ' current security settings.
        Dim fSecurity As FileSecurity = File.GetAccessControl(fileName)

        ' Add the FileSystemAccessRule to the security settings. 
        Dim accessRule As FileSystemAccessRule
 = _
            New FileSystemAccessRule(account, rights, controlType)

        fSecurity.AddAccessRule(accessRule)

        ' Set the new access settings.
        File.SetAccessControl(fileName, fSecurity)

    End Sub


    ' Removes an ACL entry on the specified file for the specified account.
    Sub RemoveFileSecurity(ByVal fileName As
 String, ByVal account As
 String, _
        ByVal rights As FileSystemRights, ByVal
 controlType As AccessControlType)

        ' Get a FileSecurity object that represents the 
        ' current security settings.
        Dim fSecurity As FileSecurity = File.GetAccessControl(fileName)

        ' Add the FileSystemAccessRule to the security settings. 
        fSecurity.RemoveAccessRule(New FileSystemAccessRule(account,
 _
            rights, controlType))

        ' Set the new access settings.
        File.SetAccessControl(fileName, fSecurity)

    End Sub
End Module
using System;
using System.IO;
using System.Security.AccessControl;

namespace FileSystemExample
{
    class FileExample
    {
        public static void
 Main()
        {
            try
            {
                string fileName = "test.xml";

                Console.WriteLine("Adding access control entry for
 " 
                    + fileName);

                // Add the access control entry to the file.
                AddFileSecurity(fileName, @"DomainName\AccountName",
                    FileSystemRights.ReadData, AccessControlType.Allow);

                Console.WriteLine("Removing access control entry from "
 
                    + fileName);

                // Remove the access control entry from the file.
                RemoveFileSecurity(fileName, @"DomainName\AccountName",
 
                    FileSystemRights.ReadData, AccessControlType.Allow);

                Console.WriteLine("Done.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }

        // Adds an ACL entry on the specified file for the specified
 account.
        public static void
 AddFileSecurity(string fileName, string account,
 
            FileSystemRights rights, AccessControlType controlType)
        {
            

            // Get a FileSecurity object that represents the 
            // current security settings.
            FileSecurity fSecurity = File.GetAccessControl(fileName);

            // Add the FileSystemAccessRule to the security settings.
 
            fSecurity.AddAccessRule(new FileSystemAccessRule(account
,
                rights, controlType));

            // Set the new access settings.
            File.SetAccessControl(fileName, fSecurity);

        }

        // Removes an ACL entry on the specified file for the specified
 account.
        public static void
 RemoveFileSecurity(string fileName, string
 account, 
            FileSystemRights rights, AccessControlType controlType)
        {

            // Get a FileSecurity object that represents the 
            // current security settings.
            FileSecurity fSecurity = File.GetAccessControl(fileName);

            // Add the FileSystemAccessRule to the security settings.
 
            fSecurity.RemoveAccessRule(new FileSystemAccessRule(account
,
                rights, controlType));

            // Set the new access settings.
            File.SetAccessControl(fileName, fSecurity);

        }
    }
}
using namespace System;
using namespace System::IO;
using namespace System::Security::AccessControl;

// Adds an ACL entry on the specified file for the specified account.

void AddFileSecurity(String^ fileName, String^ account, 
                        FileSystemRights rights, AccessControlType controlType)
{
    // Get a FileSecurity object that represents the 
    // current security settings.
    FileSecurity^ fSecurity = File::GetAccessControl(fileName);

    // Add the FileSystemAccessRule to the security settings. 
    fSecurity->AddAccessRule(gcnew FileSystemAccessRule
                                   (account,rights, controlType));

    // Set the new access settings.
    File::SetAccessControl(fileName, fSecurity);
}

// Removes an ACL entry on the specified file for the specified account.

void RemoveFileSecurity(String^ fileName, String^ account, 
                        FileSystemRights rights, AccessControlType controlType)
{

    // Get a FileSecurity object that represents the 
    // current security settings.
    FileSecurity^ fSecurity = File::GetAccessControl(fileName);

    // Remove the FileSystemAccessRule to the security settings. 
    fSecurity->RemoveAccessRule(gcnew FileSystemAccessRule
                                      (account,rights, controlType));

    // Set the new access settings.
    File::SetAccessControl(fileName, fSecurity);
}

int main()
{
    try
    {
        String^ fileName = "test.xml";

        Console::WriteLine("Adding access control entry for
 " + fileName);

        // Add the access control entry to the file.
        AddFileSecurity(fileName, "MYDOMAIN\\MyAccount", 
            FileSystemRights::ReadData, AccessControlType::Allow);

        Console::WriteLine("Removing access control entry from " + fileName);

        // Remove the access control entry from the file.
        RemoveFileSecurity(fileName, "MYDOMAIN\\MyAccount", 
            FileSystemRights::ReadData, AccessControlType::Allow);

        Console::WriteLine("Done.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine(ex->Message);
    }
}

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Security.AccessControl 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「FileSystemRights 列挙体」の関連用語

FileSystemRights 列挙体のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



FileSystemRights 列挙体のページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS