我在Windows资源管理器中打开VB.net中的特定文件夹时遇到问题.我用了
Process.Start("explorer.exe", "Folder_Path")
总是在我尝试这个时它在资源管理器中打开文档,无论我写什么.请帮忙.
Mar*_*vic 40
Process.Start("目录路径")
尝试打开它:
Process.Start("explorer.exe", "/root,Folder_Path")
Run Code Online (Sandbox Code Playgroud)
或者之前更改路径:
SetCurrentDirectory("Folder_Path")
Process.Start("explorer.exe")
Run Code Online (Sandbox Code Playgroud)
如果仍然失败,请使用shell命令:
Shell("explorer Folder_Path", AppWinStyle.NormalFocus)
Run Code Online (Sandbox Code Playgroud)
您可以使用这样的预选目录启动资源管理器:
Process.Start("explorer.exe", String.Format("/n, /e, {0}", "d:\yourdirectory\"))
Run Code Online (Sandbox Code Playgroud)
此Microsoft 知识库文章中解释了 Windows 资源管理器选项。
它仅打开默认目录(MyDocuments)的原因可能是以下两个原因之一:
·该目录不存在。
·目录路径的名称中包含空格,并且包含空格的参数应使用双引号引起来,这是编程的BASIC规则。
然后正确使用语法:
Dim Proc As String = "Explorer.exe"
Dim Args As String =
ControlChars.Quote &
IO.Path.Combine("C:\", "Folder with spaces in the name") &
ControlChars.Quote
Process.Start(Proc, Args)
Run Code Online (Sandbox Code Playgroud)