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

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 ....
LVL 2
Jayesh AcharyaTechnichal ConsultantAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Todd GerbertConnect With a Mentor IT ConsultantCommented:
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
 
QPRCommented:
string strNewCmdLine = strCmdLine.Replace("#","");

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

0
 
timexistCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Jayesh AcharyaTechnichal ConsultantAuthor Commented:
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
 
Jayesh AcharyaTechnichal ConsultantAuthor Commented:
to use char c = 34;
is the dll that i need to add??
0
 
Jayesh AcharyaTechnichal ConsultantAuthor Commented:
this worked
0
All Courses

From novice to tech pro — start learning today.