Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 852
  • Last Modified:

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 ....
0
jhacharya
Asked:
jhacharya
1 Solution
 
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
 
jhacharyaAuthor 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
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!

 
jhacharyaAuthor Commented:
to use char c = 34;
is the dll that i need to add??
0
 
Todd GerbertIT 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
 
jhacharyaAuthor Commented:
this worked
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now