Solved

System.Diagnostics.Process.Start(strCmdLine); ignore special chars?

Posted on 2010-09-21
6
828 Views
Last Modified: 2012-05-10
strCmdLine = "ifsapf://" + IFS_CMD_STR + IFS_CMD_QRY;
                        System.Diagnostics.Process.Start(strCmdLine);
                        process1.Close();

my strCmdLine sometimes contains a # characters, in one example the string was

ifsapf://scott/tiger#1@test:customer=1

but what the System.Diagnostics.Process.Start(strCmdLine); does is reinterpret the string and produces


ifsapf://scott/tiger:customer=1#1@test

which for me causes the new applaiciton to fail ...the question i have is how do ignore the # i dont know where in the string it might be, sinces its a users password they can use anything ...
some help would be appreciated ....
0
Comment
Question by:jhacharya
6 Comments
 
LVL 29

Expert Comment

by:QPR
ID: 33732120
string strNewCmdLine = strCmdLine.Replace("#","");

this will lose the # if that's all you need?

0
 
LVL 4

Expert Comment

by:timexist
ID: 33732339
you can wrap them.

http://stackoverflow.com/questions/2210212/process-start-argument-problem-escaping-an-character
strCmdLine = "ifsapf://" + IFS_CMD_STR + IFS_CMD_QRY;



            char c = 34;

            strCmdLine = c.ToString() + strCmdLine + c.ToString();



            System.Diagnostics.Process.Start(strCmdLine);

            process1.Close();

Open in new window

0
 
LVL 2

Author Comment

by:jhacharya
ID: 33734620
char c = 34;
is not allowed when i try to compile. i get Constant value 34 cannot be converted to char.

AlsoI can not remove the # or any other special char, as these are used as part of the users password. I need to be able to ignore them ...
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Author Comment

by:jhacharya
ID: 33734654
to use char c = 34;
is the dll that i need to add??
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 33738471
1. Character constants should be written as char c = (char)35; or char c = '\x0022'; (the quote character's value is 34, and in hex that's 0x22).
2. I'm relatively certain that Process.Start() is not modifying your command line, it must be the application that's registered for the ifsapf:// protocol changing it on you.  I wrote a quick protocol handler that just writes out to the console the URL, and if I use Process.Start("ifsapf://scott/tiger#1@test:customer=1"); in another application, the protocol handler outputs  ifsapf://scott/tiger#1@test:customer=1
0
 
LVL 2

Author Closing Comment

by:jhacharya
ID: 33782896
this worked
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now