how do i run paint.exe with process.start specifying a file to open?
p.s. paint isn't my default image viewer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Process.Start("C:\WINDOWS\system32\mspaint.exe", "C:\Ice-128x128.JPG")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim filename As String = "c:\documents and settings\test.bmp"
System.Diagnostics.Process.Start("mspaint.exe", Chr(34) & filename & Chr(34))
End Sub
It's got nothing to do with Process.Start. The second parameter is just a string which is appended to the commandline when the file is executed. Just as when you run a commandline yourself, if you want a value that contains spaces to be treated as a single argument then you have to enclose it in double quotes. Chr(34) will work fine, but there's no reason not to just use literal double quotes:why doesn't process.start recognise my filename?
VB.NET:dim filename as string = "c:\documents and settings\test.bmp" System.Diagnostics.Process.Start("mspaint.exe", fileName)
Process.Start("mspaint", """" & filename & """")
No it shouldn't. Try putting three double quotes together and see what the IDE tells you. It cause a syntax error. If you want to include double quotes in string literals you must escape them with a second double quote, to indicate that it is a literal character and not the string terminator.shouldn't that be """ andnot """"?