方法 : Visual Basic で My Documents ディレクトリの内容を取得する

更新 : 2007 年 11 月

My.Computer.FileSystem.SpecialDirectories オブジェクトを使用すると、Desktop や My Documents など、多くの All Users ディレクトリを読み取ることができます。

My Documents フォルダを読み取るには

  • 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)
    

参照

参照

My.Computer.FileSystem.SpecialDirectories オブジェクト

My.Computer.FileSystem.SpecialDirectories オブジェクトのメンバ

My.Computer.FileSystem.ReadAllText メソッド