我试图搜索文件"prince.exe"
,并使用VB.Net检索它的文件路径,但我找不到这样做的方法。我想你可能能够使用命令提示符,但我不确定如何。
Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Search for file and retrive path'
End Sub
答案 0 :(得分:0)
Use the GetFiles function of System.IO.Directory. Make sure to use the overload that lets you pass the SearchOption value of AllDirectories.
Dim strStartingDirectory As String = "C:\YourStarting\Directory\"
Dim lstMatches As List(of string) = System.IO.Directory.GetFiles(strStartingDirectory, _
"prince.exe", System.IO.SearchOption.AllDirectories).ToList()