Passing filename with spaces to a shelled app?

  • Thread starter Thread starter SStory
  • Start date Start date
S

SStory

I have an exe and need to pass a filepath which has spaces and would
normally be surrounded by " " if done from the Window Start -- Run dialog...

How can I get the quotes around the strings I pass to it?

Thanks,

Shane
 
* "SStory said:
I have an exe and need to pass a filepath which has spaces and would
normally be surrounded by " " if done from the Window Start -- Run dialog...

Take a look at the 'ProcessStartInfo' class and its 'FileName' and
'Arguments' properties. You can use 'Process.Start(psi)' to start an
application, 'psi' is your instance of 'ProcessStartInfo'.
 
Escape the double-quote characters with a back-slash (\). For example,
"\"C:\\My File.doc\"" will be treated as "C:\My File.doc"

Another option is to use verbatim strings (escape " with two consequtive "
chars) and prefix the whole string with @ char as in @"""C:\My File.doc""";

Hope this is what you are looking for.

I have an exe and need to pass a filepath which has spaces and would
normally be surrounded by " " if done from the Window Start -- Run dialog...

How can I get the quotes around the strings I pass to it?

Thanks,

Shane
 
SStory said:
Is this c# or VB?


File.doc""";

It is C#.

In VB, you use double quotes, i.e. """C:\My File.doc""". There is no VB.NET
equivalent to verbatim strings, unfortunately.

/Jens
 
Sorry, it is C#.

For VB, escape " with two consequtive " chars as in """C:\My File.doc"""

Is this c# or VB?
 
Thanks... I was just wondering if there was something else I wasn't aware of
in VB.NEt....

Thanks,

shane
 

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

Back
Top