-1

vb.net を使用して、特定のディレクトリ内のすべてのファイル名をループしてラベルに表示するにはどうすればよいですか?

Dim PATH_DIR_1 As String
Dim INTERVAL_DIR_1 As String

PATH_DIR_1 = Registry.GetValue("HKEY_CLASSES_ROOT\SOFTWARE\Sidewinder", "DIR_1", "")

INTERVAL_DIR_1 = Registry.GetValue("HKEY_CLASSES_ROOT\SOFTWARE\Sidewinder", "INT_DIR_1", "")

For Each foundFile As String In (PATH_DIR_1)
    Label1.Text = (foundFile)
Next
4

3 に答える 3

0

System.IOWindowsファイルシステムを操作するためのクラスがたくさんあります。これがあなたがやりたいことの例です:

Imports System.IO

......

Sub DisplayFileList(ByRef theLabel As Label, ByVal thePath As String)

    Dim di As New DirectoryInfo(thePath)

    For Each fi As FileInfo In di.GetFiles()

        theLabel.Text &= fi.FullName 'or just fi.Name, FullName is the complete path

    Next

End Sub
于 2013-02-13T12:14:01.907 に答える
0

または

Imports System.IO
...
For Each filePathAsString In Directory.EnumerateFiles("DirPath")
   Label1.Text = filePathAsString
Next
于 2013-02-13T14:14:49.990 に答える
0

次のコマンドを使用して、ディレクトリのファイル名のリストを取得できます。

Dim sFiles() as String = System.IO.Directory.GetFiles(sDirectoryPath)

そして、あなたが望む方法でそれを追加しLabelます:

For Each s As String in sFiles
    Label1.Text &= s & "/"
Next
于 2013-02-13T12:09:53.607 に答える