VB.NET 2012:在带有通配符的文件夹中打开 .exe
VB.NET 2012: Opening a .exe in a folder with Wildcard
我想在目录中打开一个文件,其名称类似于:"file_1.8.9.exe"。它的最后 3 个数字并不总是相同,所以我想要一个通配符来打开它,我认为它看起来像:
Process.Start("*.exe")
或
Process.Start("File*")
该文件将始终是目录中唯一的.exe,因此打开所有.exe 不是问题。我已经尝试过其他方法来做到这一点,但我无法为我工作。
Try
Dim dirs As String() = Directory.GetFiles("C:\YOUR_DIRECTORY", "file_*.exe")
Dim dir As String
For Each dir In dirs
Process.Start(dir)
Next
Catch e As Exception
Console.WriteLine("The process failed: {0}", e.ToString())
End Try
我想在目录中打开一个文件,其名称类似于:"file_1.8.9.exe"。它的最后 3 个数字并不总是相同,所以我想要一个通配符来打开它,我认为它看起来像:
Process.Start("*.exe")
或
Process.Start("File*")
该文件将始终是目录中唯一的.exe,因此打开所有.exe 不是问题。我已经尝试过其他方法来做到这一点,但我无法为我工作。
Try
Dim dirs As String() = Directory.GetFiles("C:\YOUR_DIRECTORY", "file_*.exe")
Dim dir As String
For Each dir In dirs
Process.Start(dir)
Next
Catch e As Exception
Console.WriteLine("The process failed: {0}", e.ToString())
End Try