[英]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.