使用 Visual Basic 访问文件File Access with Visual Basic

My.Computer.FileSystem 对象提供用于处理文件和文件夹的工具。The My.Computer.FileSystem object provides tools for working with files and folders. 它的属性、方法和事件使你可以创建、复制、移动、调查以及删除文件和文件夹。Its properties, methods, and events allow you to create, copy, move, investigate, and delete files and folders. My.Computer.FileSystem 提供的性能比 Visual Basic 为后向兼容性提供的旧版功能(FileOpenFileCloseInputInputStringLineInput 等)的性能更好。My.Computer.FileSystem provides better performance than the legacy functions (FileOpen, FileClose, Input, InputString, LineInput, etc.) that are provided by Visual Basic for backward compatibility.

本节内容In This Section

从文件读取Reading from Files
列出有关使用 My.Computer.FileSystem 对象读取文件的主题Lists topics dealing with using the My.Computer.FileSystem object to read from files

写入文件Writing to Files
列出有关使用 My.Computer.FileSystem 对象写入文件的主题Lists topics dealing with using the My.Computer.FileSystem object to write to files

创建、删除和移动文件和目录Creating, Deleting, and Moving Files and Directories
列出有关使用 My.Computer.FileSystem 对象创建、复制、删除以及移动文件和文件夹的主题。Lists topics dealing with using the My.Computer.FileSystem object to creating, copying, deleting and moving files and folders.

使用 TextFieldParser 对象分析文本文件Parsing Text Files with the TextFieldParser Object
讨论如何使用 TextFieldReader 来解析文本文件(如日志)。Discusses how to use the TextFieldReader to parse text files such as logs.

文件编码File Encodings
描述文件编码及其用法。Describes file encodings and their use.

演练:在 Visual Basic 中操作文件和目录Walkthrough: Manipulating Files and Directories in Visual Basic
演示如何创建报告文件和文件夹相关信息的实用工具。Demonstrates how to create a utility that reports information about files and folders.

排除故障:读取和写入文本文件Troubleshooting: Reading from and Writing to Text Files
列出读取和写入文本文件时遇到的常见问题,并为每个问题提供补救措施。Lists common problems encountered when reading and writing to text files, and suggests remedies for each.