file paths and verbatim literals problem

C

CroDude

Hi!

I have and issue with passing quoted path to a extern application via
Process.Start.
When I pass argument as:
@" -o c:\test.tif c:\_script.txt c:\test.jpg "

everything works fine but I have to pass paths in quotes ... it must look
like this:

-o "c:\test.tif " "c:\_script.txt" "c:\test.jpg "

so I write this:
@" -o ""c:\test.tif"" ""c:\_script.txt"" ""c:\test.jpg"" "

but output then looks like this:
" -o \"c:\\test.tif\" \"c:\\_script.txt\" \"c:\\test.jpg\" "

as You see I got double backshlashes and single backslashes on a places
where they shouldn't be.
Any suggestions .... I'm really stuck .... again!
Thanks!
 
J

Jon Skeet [C# MVP]

CroDude said:
I have and issue with passing quoted path to a extern application via
Process.Start.
When I pass argument as:
@" -o c:\test.tif c:\_script.txt c:\test.jpg "

everything works fine but I have to pass paths in quotes ... it must look
like this:

-o "c:\test.tif " "c:\_script.txt" "c:\test.jpg "

so I write this:
@" -o ""c:\test.tif"" ""c:\_script.txt"" ""c:\test.jpg"" "

but output then looks like this:
" -o \"c:\\test.tif\" \"c:\\_script.txt\" \"c:\\test.jpg\" "

as You see I got double backshlashes and single backslashes on a places
where they shouldn't be.
Any suggestions .... I'm really stuck .... again!

See http://www.pobox.com/~skeet/csharp/strings.html#debugger
 
C

Ciaran

Try using this:

"-o \"c:\\test.tif \" \"c:\\_script.txt\" \"c:\\test.jpg \""

Ciaran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top