OpenMode OpenMode OpenMode OpenMode Enum

定义

指示调用文件访问函数时如何打开文件。Indicates how to open a file when calling file-access functions.

public enum class OpenMode
public enum OpenMode
type OpenMode = 
Public Enum OpenMode
继承

字段

Append Append Append Append 8

为向其追加内容而打开的文件。File opened to append to it. 默认。Default.

Binary Binary Binary Binary 32

为进行二进制访问而打开的文件。File opened for binary access.

Input Input Input Input 1

为进行读访问而打开的文件。File opened for read access.

Output Output Output Output 2

为进行写访问而打开的文件。File opened for write access.

Random Random Random Random 4

为进行随机访问而打开的文件。File opened for random access.

注解

调用文件访问相关的函数时, 可以在代码中使用枚举成员而不是实际值。When you call file access-related functions, you can use enumeration members in your code instead of the actual values.

枚举OpenMode定义用于设置文件访问模式的常量。The OpenMode enumeration defines constants used to set file access modes. 下表列出OpenMode了枚举成员。The following table lists the OpenMode enumeration members.

InputOutput按顺序Append访问文件 (如文本文件) 时使用、和, 而Binary用于二进制文件访问和Random随机文件访问。Input, Output, and Append are used when sequentially accessing files, such as text files, whereas Binary is used for binary file access and Random for random file access. 有关示例, 请参见FileOpen方法。For examples, see the FileOpen method.

按顺序访问某个文件时, 不能更改其数据。When sequentially accessing a file, you cannot change its data. 您可以读取数据、向其追加数据或用新数据覆盖它。You can read the data, append to it, or overwrite it with new data. 如果为输入打开该文件, 则将覆盖该文件的内容, 即使您不直接写入该文件也是如此。If you open it for input, the contents of the file will be overwritten, even if you do not directly write to the file.

执行文件 i/o 操作时, My.Computer.FileSystem对象可提供比早期文件 i/o 方法更好的性能和易用性。When performing file I/O operations, the My.Computer.FileSystem object provides better performance and ease of use than earlier file I/O methods. 有关详细信息, 请FileSystem参阅对象。For more information, see FileSystem object.

适用于

另请参阅