Opening a file with spaces in VB [HELP]

denden42

Member
Jul 21, 2013
55
0
16
hi just wanna ask how to open a file with space.. lets say i want to open a txt file in "c;\A B C\text to open.txt"

this is my code,
Process.start("wordpad.exe", "c;\A B C\text to open.txt")

and another thing, i want to put an executable file inside the bin\debug folder and call it on my app.

edit:
i intentionally put a semicolon on my post to avoid the smiley.

Regards :)
 

cabri

Diamond Member
Nov 3, 2012
3,616
1
81
Have you tried this to see what the result is.

You will need a double back slash where you are using single slashes to ensure that the slash is treated as a "slash" and not a control character
 

brandonb

Diamond Member
Oct 17, 2006
3,731
2
0
If you are hard-coding the path, then use a double - double quote:

Dim thepath as string = """c;\a b c\file.txt"""

(see how there are 3 double quotes. One is the normal string starting quotation, then an embedded quote by using the double-double quote, so you should see 3 double quotes on each end of the string)
 

KB

Diamond Member
Nov 8, 1999
5,406
389
126
and another thing, i want to put an executable file inside the bin\debug folder and call it on my app.

If you want to run an EXE thats in the same folder as your project EXE then you have to get the folder of the currently running EXE and add the name of the other EXE.

Code:
Process.Start(System.IO.Path.GetDirectoryName(Application.ExecutablePath) & "\processtorun.exe")