该 SpecialDirectories 对象可用于从许多 “所有用户 ”目录(如 “我的文档 ”或 “桌面”)读取。
读取“我的文档”文件夹
ReadAllText
使用该方法从特定目录中的每个文件读取文本。 下面的代码指定了一个目录和文件,然后使用ReadAllText
将它们读入名为patients
的字符串。Dim path As String Dim patients As String path = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\" & "Patients.txt" patients = My.Computer.FileSystem.ReadAllText(path)