Solved

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

Posted on 2010-09-21
6
841 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Windows Form Navigation - Total Beginner 9 94
array not updating 8 42
c#, case, if 4 37
GET INFO ABOUT WHAT THE PRINTER IS DOING ? 11 76
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

751 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