Solved

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

Posted on 2010-09-21
6
834 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sent email using Shared Mailbox from outlook in C# 5 24
Hey!! 5 33
Example works but why do I need to click twice on button 4 43
FTP file download using c# 3 23
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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