【发布时间】:2014-07-25 02:03:21
【问题描述】:
我正在尝试通过在 VB.Net 中创建的 Windows 窗体打开一个目录,但我发现的每个解决方案似乎都不起作用。
目前我正在使用-
Dim path As String = Directory.GetCurrentDirectory()
Private Sub logDirBTN_Click(sender As Object, e As EventArgs) Handles logDirBTN.Click
Process.Start(path + "\Resources\Logs")
End Sub
返回“系统找不到指定的文件”异常。这很有趣,因为我知道文件夹在那里。此外,此按钮的功能没有任何问题,据我所知,唯一的区别是我打开的是文本文件而不是空目录-
Private Sub stationListBTN_Click(sender As Object, e As EventArgs) Handles stationListBTN.Click
Process.Start("notepad.exe", path + "\Resources\StationList\StationList.txt")
End Sub
这是我尝试过的所有其他方法-
Private Sub logDirBTN_Click(sender As Object, e As EventArgs) Handles logDirBTN.Click
'Process.Start("explorer.exe", path + "\Resources\Logs")
'Shell("explorer.exe", path + "\Resources\Logs", vbNormalFocus)
'Application.StartupPath & path + "\Resources\Logs"
'Shell(path + "\Resources\Logs", vbNormalFocus)
End Sub
非常感谢任何帮助。
【问题讨论】:
-
它需要文件的路径,目录不能工作。如果要在目录上打开资源管理器视图,请启动 Explorer.exe