C# Adding "'" Symbol to statements
I have a statement that sets a scheduled event, although I am having trouble wrapping the last part of the statement with the ' symbols.
Process.Start("schtasks.exe", @"/Create /SC DAILY /MO" + " \"" + comboBox2.Text + "\" " + @"/ST" + " \"" + comboBox1.Text +开发者_JAVA技巧 "\" " + @"/TN" + " \"" + textBox2.Text + "\" " + @"/TR ""C:\Program Files\test\scan.exe"" " + textBox3.Text);
I am trying to get textBox3.Text as follows:
'textBox3.Text'
you can also use String.Format
String.Format("Blah blah '{0}'", textBox3.Text);
Just put the ' inside double quotes.
... + "'" + textBox3.Text + "'"
Process.Start("schtasks.exe",
string.Format(
@"/Create /SC DAILY /MO ""{0}"" /ST ""{1}"" /TN ""{2}"" /TR ""C:\Program Files\test\scan.exe"" {3}",
comboBox2.Text, comboBox1.Text,
textBox2.Text, textBox3.Text));
精彩评论