问题描述
我试着在cmd中写这样:
C:\Program Files \WinRAR\Rar.exea C:\ Users \ User &\\Desktop \\ \\ temp.zipC:\ Users\User \Desktop\img
但使用此代码:
I tried to write in cmd this as is:
"C:\Program Files\WinRAR\Rar.exe" a C:\Users\User\Desktop\temp.zip "C:\Users\User\Desktop\img"
but using this code:
Console( '"' + path_to_winrar + '"' + " a " + dest + " " + '"' +source +'"');
我得到了
\C:\\Program Files \\WinRAR \\Rar.exe \ 一个C:\\Users \\User \\Desktop \\ 18.12.2012.zip \C:\\Users\\User \\Desktop \ \\ img \\\
如何?
I got
"\"C:\\Program Files\\WinRAR\\Rar.exe\" a C:\\Users\\User\\Desktop\\18.12.2012.zip \"C:\\Users\\User\\Desktop\\img\\\""
How?
推荐答案
string s = '"' + "hello" + '"' + " " + '"' + "!" + '"';
Console.WriteLine(s);
控制台将显示
你好!
和调试器wi ll show
\hello \\!\
Alan。
The Console will show"hello" "!"
and the debugger will show"\"hello\" \"!\""
Alan.
string path_to_winrar = @"C:\Program Files\WinRAR\Rar.exe";
string dest = @"C:\Users\User\Desktop\temp.zip";
string source = @"C:\Users\User\Desktop\img";
string result = string.Format("\"{0}\" a {1} \"{2}\"", path_to_winrar, dest, source);
我希望这会有所帮助。
谢谢:)
I hope this will help.
Thanks :)
这篇关于如何在字符串中写双引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!