Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 字符串中的引号_C#_String_Quotation Marks - Fatal编程技术网

C# 字符串中的引号

C# 字符串中的引号,c#,string,quotation-marks,C#,String,Quotation Marks,我有一些带变量的字符串,例如 string path = @"C:\one\filename.exe" + arguments arguments: "-s -c -d > "somedirectory\some file.txt"" 我无法将输出重定向到“somedirectory\somefile” 如果我把“\”或char.ToString(“”)放进去,它总是解释为\”…不仅仅是“ 如何将此“字符放入参数中?您需要使用\” 调试器将其显示为\“,因为它显示有效的字符串文本。 但

我有一些带变量的字符串,例如

string path = @"C:\one\filename.exe" + arguments

arguments: "-s -c -d > "somedirectory\some file.txt""
我无法将输出重定向到
“somedirectory\somefile”
如果我把
“\”
char.ToString(“”)
放进去,它总是解释为
\”
…不仅仅是

如何将此
字符放入参数中?

您需要使用
\”

调试器将其显示为
\“
,因为它显示有效的字符串文本。
但是,字符串中的实际值为
。(您可以在文本可视化工具中看到这一点)

在逐字字符串文本(
@“…”
)中,您需要使用

var arguments =  @"-s -c -d > ""somedirectory\some file.txt""";

试试看


有关详细信息,

此路径位于*.bat文件中。那么为什么它不能从代码中运行,如果我手动运行这个bat文件,它工作正常?如果我从bat文件中运行这一行,它工作C:\one\filename.exe“-s-C-d>“somedirectory\somefile.txt”暂停,但在代码中它不工作。你是在代码中运行它吗?你应该改用
重定向标准输出
var arguments = "-s -c -d > \"somedirectory\\some file.txt\"";
string args = @"-s -c -d > ""somedirectory\some file.txt"""