[英]VB.NET, open specific folder in windows explorer?
I have problem with opening specific folder in VB.net in Windows Explorer. 我在Windows资源管理器中打开VB.net中的特定文件夹时遇到问题。 I used
我用了
Process.Start("explorer.exe", "Folder_Path")
Always when i tried this it open documents in explorer , whatever i wrote. 总是当我尝试这个时它在资源管理器中打开文档,无论我写什么。 Pls help.
请帮忙。
Process.Start(“目录路径”)
Try opening it with: 尝试打开它:
Process.Start("explorer.exe", "/root,Folder_Path")
Or change the path before: 或者之前更改路径:
SetCurrentDirectory("Folder_Path")
Process.Start("explorer.exe")
And if it still fails, go with the shell command: 如果仍然失败,请使用shell命令:
Shell("explorer Folder_Path", AppWinStyle.NormalFocus)
The reason why it opens the default directory (MyDocuments) only could be one of these two reasons: 它只打开默认目录(MyDocuments)的原因可能是以下两个原因之一:
· The directory does not exist. ·目录不存在。
· The directory path contains spaces in the name, and arguments containing spaces should be enclosed with doublequotes, this is a BASIC rule of programming. ·目录路径在名称中包含空格,包含空格的参数应该用双引号括起来,这是编程的BASIC规则。
Then use the syntax properrlly: 然后正确使用语法:
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)
You could start explorer with preselected directory like this: 您可以使用预先选择的目录启动资源管理器,如下所示:
Process.Start("explorer.exe", String.Format("/n, /e, {0}", "d:\yourdirectory\"))
The Windows Explorer options are explained in this Microsoft KB article . 此Microsoft知识库文章中介绍了Windows资源管理器选项。
Process.Start("explorer.exe", "/select," + "C:\File_Name.txt")
.txt可能是你需要的。
You can try Process.Start("explorer.exe", "Folder_Path") like you said. 你可以像你说的那样尝试Process.Start(“explorer.exe”,“Folder_Path”)。 The only reason that windows explorer opens the documents folder is that you mistype the "folder_path" and the specified folder doen not exists
Windows资源管理器打开文档文件夹的唯一原因是您输入错误的“folder_path”并且指定的文件夹不存在
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.