我有一个很长的字符串,我想把变量放入,但我不能
string body = @"-----------------------------13254316446590
Content-Disposition: form-data; name=""max_file_size""
100000
-----------------------------13254316446590
Content-Disposition: form-data; name=""uploadedfile""; filename=""file.txt""
Content-Type: application/octet-stream
<!>C:\Users\anton\AppData\Local\Temp\lost\file.txt<!>
-----------------------------13254316446590--
";
我想制作路径和文件名变量 我知道这看起来像一个愚蠢的问题,但我试图把“”+“”没有成功
答案 0 :(得分:1)
您是否尝试过使用String.Format(...)
?
http://msdn.microsoft.com/en-us/library/system.string.format%28v=vs.110%29.aspx
示例:
DateTime dat = new DateTime(2012, 1, 17, 9, 30, 0);
string city = "Chicago";
int temp = -16;
string output = String.Format("At {0} in {1}, the temperature was {2} degrees.",
dat, city, temp);
Console.WriteLine(output);
// The example displays the following output:
// At 1/17/2012 9:30:00 AM in Chicago, the temperature was -16 degrees.
答案 1 :(得分:1)
尝试String.Format()
String.Format("some string {0} other string {1}", path, filename);
MSDN Article,它可以帮到你。