我正在将信息写入文件,并将其命名为"//Average+DateTime.txt"
; 我认为我的代码会比我试图澄清的更容易:
String path=bama();
if(path.Contains(".txt")) {
StreamWriter sw=
new StreamWriter(
"C:/Users/msilliman11/Average"
+DateTime.Now.ToString("yyyyMMdd")
+".txt"
);
}
String ElementsNum=RoundedValues.Count.ToString();
DateTime dt=System.DateTime.Now;
using(var NewFile=File.Create(path)) {
using(var writeIt=new StreamWriter(NewFile)) {
writeIt.Write(
"NA"+","
+dt.Hour.ToString()+","+dt.Minute+","
+dt.Day+","+dt.Month.ToString()+","+dt.Year.ToString()+","
+"ALTEST "+","+"ALTEST "+","+heatgrade
+" "+","+" "+","+heatname+","
+DT2.Columns[3].ToString()+","+heatgrade+","
+"OE2"+","+","+","+","+","+","+","+" "+ElementsNum+","
);
foreach(
var pair in
RoundedValues.Zip(
Elements, (a, b) => new {
A=a,
B=b
})) {
writeIt.Write(pair.B.ToString()+","+pair.A.ToString()+",");
}
}
}
我遇到的问题是我需要命名"Average"
文件,并将外部 using 块中的代码写入文件...
我很不擅长解释这些问题,但基本上我试图在第二个 using 块中获取信息,以便"4222013Average.txt"
在输出文件中命名......