-
April 9th, 2013, 04:20 PM
#1
Sting with Quotes Issue
Hello,
I have been trying for hours to understand how to escape with double quotes and have had no luck.
I need to pass a string to a process.start arguments line like this.
String DF = @"C:\temp\test\backups\";
But need to add double quotes only to the front side of this line, like this when executed:
"C:\temp\test\backups\
And not like this:
"C:\temp\test\backups\"
And cannot figure out how to do it.
I have tried "\""
Any help would be great thanks,
Mike
-
April 9th, 2013, 04:47 PM
#2
Re: Sting with Quotes Issue
Code:
var df = @"C:\temp\test\backups\";
// var df = "\"" + @"C:\temp\test\backups\";
Console.WriteLine(df);
if (df[0] != '\"')
{
df = "\"" + df;
}
Console.WriteLine(df);
That being said, want you probably want to do is form the complete portion of the string that needs to be double quoted and then write a method that checks and quotes the ends as necessary. This ends up being easier to follow than quoting the beginning forming the rest of the string and then quoting the end (plus the method is reusable).
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
|