|
-
May 4th, 2012, 11:02 AM
#1
Escape Double Quote Problem
Hello,
I'm having trouble figuring out how to add a single double quote in my string.
My Code line
Code:
String Commandstr1 = @"C:\Temp\eventcombMT.exe" + " /file:" + "\"" + @"C:\Temp\servers.txt";
This is what debug looks like:
Commandstr1 "C:\\Temp\\eventcombMT.exe /file:\"C:\\Temp\\servers.txt" string
See that it is adding the unneeded \ after file:
My need result line:
eventcombmt.exe /file:"C:\Temp\servers.txt";
Can anyone see my problem with escaping this one "
Thanks,
Mike
-
May 4th, 2012, 12:33 PM
#2
Re: Escape Double Quote Problem
It most likely has to do with the @ symbol you're using. That symbol is used to signify that the string is already as you would like it, and to ignore escape characters. I know you're only using it in front of the strings you want to use it in front of, but it might not be possible to mix them that way. I would just do this:
Code:
String Commandstr1 = "C:\\Temp\\eventcombMT.exe /file:\"C:\\Temp\\servers.txt";
-
May 4th, 2012, 02:30 PM
#3
Re: Escape Double Quote Problem
I tryied removing the @, but it still does not like it.
I need to have the " in the string code for the app that I'm passing it to.
Thanks,
Mike
-
May 7th, 2012, 04:21 PM
#4
Re: Escape Double Quote Problem
 Originally Posted by netman06
I tryied removing the @, but it still does not like it.
I need to have the " in the string code for the app that I'm passing it to.
Thanks,
Mike
When using the @ sign you should use "" for quotes.
i.e.
@"eventcombmt.exe /file:""C:\Temp\servers.txt"";"
-
May 7th, 2012, 04:24 PM
#5
Re: Escape Double Quote Problem
Code:
String Commandstr1 = @"C:\Temp\eventcombMT.exe /file:""C:\Temp\servers.txt""";
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|