![](/img/trans.png)
[英]Open Windows Explorer from VB.NET: doesn't open in the right folder
[英]VB.NET, open specific folder in windows explorer?
我在Windows资源管理器中打开VB.net中的特定文件夹时遇到问题。 我用了
Process.Start("explorer.exe", "Folder_Path")
总是当我尝试这个时它在资源管理器中打开文档,无论我写什么。 请帮忙。
Process.Start(“目录路径”)
尝试打开它:
Process.Start("explorer.exe", "/root,Folder_Path")
或者之前更改路径:
SetCurrentDirectory("Folder_Path")
Process.Start("explorer.exe")
如果仍然失败,请使用shell命令:
Shell("explorer Folder_Path", AppWinStyle.NormalFocus)
它只打开默认目录(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)
您可以使用预先选择的目录启动资源管理器,如下所示:
Process.Start("explorer.exe", String.Format("/n, /e, {0}", "d:\yourdirectory\"))
此Microsoft知识库文章中介绍了Windows资源管理器选项。
Process.Start("explorer.exe", "/select," + "C:\File_Name.txt")
.txt可能是你需要的。
你可以像你说的那样尝试Process.Start(“explorer.exe”,“Folder_Path”)。 Windows资源管理器打开文档文件夹的唯一原因是您输入错误的“folder_path”并且指定的文件夹不存在
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.