[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Specifying System.Diagnostics.Process.Start parameters with spaces in a parameter string

Posted on 2006-05-01
3
Medium Priority
?
5,950 Views
Last Modified: 2010-08-05
Hello,

I have a C# application that calls a process from the C# code.

One of the parameters is a filepath.  This works fine - as long as there are no spaces in the filepath.  If there are spaces in the filepath name, the app breaks.

For example, this works:

System.Diagnostics.Process.Start("c:\\Programs\\WinRar\\WinRar", "e c:\\Temp\\*.rar *.rcp");


This, however, does not work (notice that the only difference is that there is a space in the filepath string in the second argument):

System.Diagnostics.Process.Start("c:\\Programs\\WinRar\\WinRar", "e c:\\Temp Files\\*.rar *.rcp");

Thanks in advance,
Tim
0
Comment
Question by:tmitchell68
  • 2
3 Comments
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 total points
ID: 16582346
Try...

    System.Diagnostics.Process.Start(@"c:\Programs\WinRar\WinRar", @"e ""c:\Temp Files\*.rar"" *.rcp");
0
 
LVL 2

Accepted Solution

by:
patspam earned 1000 total points
ID: 16583282
Try: System.Diagnostics.Process.Start("c:\\Programs\\WinRar\\WinRar", "e \"c:\\Temp Files\\*.rar\" *.rcp");

Eg, put in backslash-escaped quotes around the path with spaces, so that they don't get treated as 2 separate arguments.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16585438
That's exactly what I have done patspam...except I used the @ symbol in front of the string with double-double quotes...same end difference.  =)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question