|
-
Oct 24th, 2023, 12:37 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Open Windows Explorer to folder opens Documents folder instead of Folder Path
Hi,
When I have spaces and/or unusual characters in a folder path the following code opens the user's Documents folder instead of the intended path.
Is there any way to fix it?
Code:
Dim FolderPath As String = "C:\A,B 1.1"
If System.IO.Directory.Exists(FolderPath) Then
Process.Start("explorer.exe", FolderPath)
Else
MsgBox("Path does not exist")
End If
-
Oct 24th, 2023, 02:37 PM
#2
Re: Open Windows Explorer to folder opens Documents folder instead of Folder Path
Try passing FolderPath surrounded by double quotes.
Multiple ways of doing this, one option:
Code:
Process.Start("explorer.exe", Chr(34) & FolderPath & Chr(34))
Last edited by OptionBase1; Oct 24th, 2023 at 02:40 PM.
-
Oct 24th, 2023, 02:43 PM
#3
Re: Open Windows Explorer to folder opens Documents folder instead of Folder Path
As OB1 suggested, double quotes are needed...
Code:
Dim FolderPath As String = "C:\A,B 1.1"
Process.Start("explorer.exe", String.Format("/n, /e, ""{0}""", "C:\A,B 1.1\"))
See command line options here:
https://ss64.com/nt/explorer.html
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 25th, 2023, 05:31 AM
#4
Thread Starter
Fanatic Member
Re: Open Windows Explorer to folder opens Documents folder instead of Folder Path
That's great.
Thank you both.
-
Oct 25th, 2023, 07:17 PM
#5
Re: [RESOLVED] Open Windows Explorer to folder opens Documents folder instead of Fold
This was not a programming problem. Process.Start basically just mimics what you can do from the commandline. You should have used a console window to get your commandline right first. If you'd done that then you'd have seen that quotes were required around a path that contained spaces. Of course they would be, given that spaces are the delimiters between arguments.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|