我要检索记事本txt文件的目录,但我只有记事本的部分文件名?有可能这样做,任何快速的方式?我正在使用vb 2010 express来获取您的信息
答案 0 :(得分:0)
''' <summary>
''' Gets all dirctories containing the file which its part is specified.
''' </summary>
''' <param name="PartOfTXT">The file specified. Do not contain the TXT extension.</param>
''' <returns>All dirctories containing the file which its part is specified.</returns>
''' <remarks>Comment if anything is wrong.</remarks>
Function GetTXTDirectory(PartOfTXT As String) As String()
Dim List As New System.Collections.Generic.List(Of String)
For Each Drive As System.IO.DriveInfo In System.IO.DriveInfo.GetDrives
List.AddRange(System.IO.Directory.GetFiles(
Drive.Name, "*"c & PartOfTXT & "*.txt", IO.SearchOption.AllDirectories))
Next
Return List.ToArray
End Function