FileIOPermissionAttribute クラス

定義

注意事項

Code Access Security is not supported or honored by the runtime.

FileIOPermission のセキュリティ アクションを、宣言セキュリティを使用してコードに適用できるようにします。 このクラスは継承できません。

public ref class FileIOPermissionAttribute sealed : System::Security::Permissions::CodeAccessSecurityAttribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)]
public sealed class FileIOPermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)]
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class FileIOPermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)]
[System.Serializable]
public sealed class FileIOPermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class FileIOPermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)>]
type FileIOPermissionAttribute = class
    inherit CodeAccessSecurityAttribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)>]
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type FileIOPermissionAttribute = class
    inherit CodeAccessSecurityAttribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)>]
[<System.Serializable>]
type FileIOPermissionAttribute = class
    inherit CodeAccessSecurityAttribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type FileIOPermissionAttribute = class
    inherit CodeAccessSecurityAttribute
Public NotInheritable Class FileIOPermissionAttribute
Inherits CodeAccessSecurityAttribute
継承
属性

次のコード例は、 クラスを使用FileIOPermissionAttributeして要求FileIOPermissionする方法を示しています。この方法は、コードに付与される唯一のアクセス許可を示しています。

[FileIOPermissionAttribute(SecurityAction::PermitOnly,ViewAndModify="C:\\example\\sample.txt")]
[FileIOPermissionAttribute(SecurityAction.PermitOnly, ViewAndModify = "C:\\example\\sample.txt")]
<FileIOPermissionAttribute(SecurityAction.PermitOnly, _
ViewAndModify:="C:\example\sample.txt")> Public Class SampleClass

次の例は、呼び出し元のコードに 無制限 FileIOPermissionの を要求する方法を示しています。 通常は、有害な可能性のあるコードからメソッドまたはクラスを保護するために、マネージド ライブラリ (DLL) で要求を行います。

[FileIOPermissionAttribute(SecurityAction::Demand,Unrestricted=true)]
[FileIOPermissionAttribute(SecurityAction.Demand, Unrestricted=true)]
<FileIOPermissionAttribute(SecurityAction.Demand, _
 Unrestricted := True)> Public Class SampleClass

注釈

注意事項

コード アクセス セキュリティ (CAS) は、.NET Framework と .NET のすべてのバージョンで非推奨になりました。 最近のバージョンの .NET では、CAS 関連の API が使われている場合、CAS の注釈は使われず、エラーが発生します。 開発者は、代わりの手段を見つけてセキュリティ タスクを実現する必要があります。

ファイルとディレクトリは、絶対パスを使用して指定されます。 ファイルにアクセスすると、ファイルの作成時または開き時にセキュリティ チェックが実行されます。 ファイルを閉じて再度開かない限り、セキュリティ チェックは再度実行されません。 ファイルに初めてアクセスするときにアクセス許可を確認すると、アプリケーションのパフォーマンスに対するセキュリティ チェックの影響が最小限に抑えられます。これは、ファイルを開く操作が 1 回だけ行われるのに対し、読み取りと書き込みは複数回発生する可能性があるためです。

許可される宣言のスコープは、使用される によって SecurityAction 異なります。

セキュリティ属性によって宣言されたセキュリティ情報は、属性ターゲットのメタデータに格納され、実行時にシステムによってアクセスされます。 セキュリティ属性は、宣言型セキュリティにのみ使用されます。 命令型セキュリティの場合は、対応するアクセス許可クラスを使用します。

注意事項

UnrestrictedFileIOPermission は、1 つのファイルへのアクセスに使用できる複数のパス名を含む、ファイル システム内のすべてのパスに対するアクセス許可を付与します。 ファイルにアクセスするには Deny 、ファイルに対して可能なすべてのパスが必要 Deny です。 たとえば、\\server\share がネットワーク ドライブ X にマップされている場合、\\server\share\file にアクセスするには Deny 、\\server\share\file、X:\file、およびそのファイルへのアクセスに使用できるその他のパスが必要 Deny です。

コンストラクター

FileIOPermissionAttribute(SecurityAction)
古い.

FileIOPermissionAttribute を指定して、SecurityAction クラスの新しいインスタンスを初期化します。

プロパティ

Action
古い.

セキュリティ アクションを取得または設定します。

(継承元 SecurityAttribute)
All
古い.
古い.
古い.

文字列値で指定されるファイルまたはディレクトリへのフル アクセスを取得または設定します。

AllFiles
古い.

すべてのファイルへの許可されたアクセスを取得または設定します。

AllLocalFiles
古い.

すべてのローカル ファイルへの許可されたアクセスを取得または設定します。

Append
古い.

文字列値で指定されるファイルまたはディレクトリへの追加アクセスを取得または設定します。

ChangeAccessControl
古い.

アクセス制御情報を変更できるファイルまたはディレクトリを取得または設定します。

PathDiscovery
古い.

パス探索を与えるファイルまたはディレクトリを取得または設定します。

Read
古い.

文字列値が指定するファイルまたはディレクトリへの読み取りアクセスを取得または設定します。

TypeId
古い.

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)
Unrestricted
古い.

属性によって保護されているリソースに対して完全な (無制限の) アクセス許可が宣言されているかどうかを示す値を取得または設定します。

(継承元 SecurityAttribute)
ViewAccessControl
古い.

アクセス制御情報を表示できるファイルまたはディレクトリを取得または設定します。

ViewAndModify
古い.

ファイル データを表示して変更できるファイルまたはディレクトリを取得または設定します。

Write
古い.

文字列値が指定するファイルまたはディレクトリへの書き込みアクセスを取得または設定します。

メソッド

CreatePermission()
古い.

新しい FileIOPermission を作成して返します。

Equals(Object)
古い.

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()
古い.

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()
古い.

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()
古い.

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)
古い.

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()
古い.

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()
古い.

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)
古い.

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)
古い.

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)
古い.

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)
古い.

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください