FileAccess 枚举
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
定义文件的读取、写入或读/写访问权限的常量。
此枚举支持其成员值的按位组合。
public enum class FileAccess
C#
[System.Flags]
public enum FileAccess
C#
[System.Flags]
[System.Serializable]
public enum FileAccess
C#
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum FileAccess
[<System.Flags>]
type FileAccess =
[<System.Flags>]
[<System.Serializable>]
type FileAccess =
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type FileAccess =
Public Enum FileAccess
- 继承
- 属性
名称 | 值 | 说明 |
---|---|---|
Read | 1 | 对文件的读访问。 可从文件中读取数据。 与 |
ReadWrite | 3 | 对文件的读写访问权限。 可从文件读取数据和将数据写入文件。 |
Write | 2 | 文件的写访问。 可将数据写入文件。 与 |
以下 FileStream
构造函数授予对现有文件 (FileAccess.Read
) 的只读访问权限。
FileStream^ s2 = gcnew FileStream( name, FileMode::Open, FileAccess::Read, FileShare::Read );
C#
FileStream s2 = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read);
let s2 = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim s2 As New FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read)
有关创建文件和将文本写入文件的示例,请参阅 如何:将文本写入文件。 有关从文件读取文本的示例,请参阅 如何:从文件中读取文本。 有关读取和写入二进制文件的示例,请参阅 如何:读取和写入新创建的数据文件。
FileAccess
参数在 、FileInfoFileStream、 和其他构造函数的许多构造函数File中指定,在这些构造函数中,控制用户对文件的访问权限类型非常重要。
产品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |