写入文件帮助c#
Write to file help c#
我正在从文件中获取数据并计算状态代码并将其写入文件。当我 运行 程序时,它确实将 StatusCode 与其他数字分开,并且在 visual studio 的输出中,计数是正确的,但文件是空白的,没有任何内容写入它。我已经研究过内联但仍然无法弄清楚。任何帮助,将不胜感激。谢谢
using (StreamWriter file1 = new StreamWriter(@"C:\GIT\ELF\csharp\examples\EROIRSImport_sln\EROIRSImport\EROIRSImport\List.txt"))
{
for (int i = 0; i >= dataInputList.Count; i++)
{
DataInput di = dataInputList[i];
file1.WriteLine("EFIN: "+di.getEFIN()+" StatusCode: "+di.getStatusCode()+" StatusDate: "+di.getStatusDate());
}
}
for (int i = 0; i >= dataInputList.Count; i++)
看来你的比较倒退了,我的朋友。应该是:
for (int i = 0; i < dataInputList.Count; i++)
我还要删除 =
,因为计数是 non-zero,并且 i
从 0
开始
string path = @"C:\GIT\ELF\csharp\examples\EROIRSImport_sln\EROIRSImport\EROIRSImport\List.txt";
var lines = dataInputList.Select(di => $"EFIN: {di.GetEFIN()}\tStatusCode: {di.getStatusCode()}\tStatusDate: {di.getStatusDate()}");
File.WriteAllLines(path, lines);
我正在从文件中获取数据并计算状态代码并将其写入文件。当我 运行 程序时,它确实将 StatusCode 与其他数字分开,并且在 visual studio 的输出中,计数是正确的,但文件是空白的,没有任何内容写入它。我已经研究过内联但仍然无法弄清楚。任何帮助,将不胜感激。谢谢
using (StreamWriter file1 = new StreamWriter(@"C:\GIT\ELF\csharp\examples\EROIRSImport_sln\EROIRSImport\EROIRSImport\List.txt"))
{
for (int i = 0; i >= dataInputList.Count; i++)
{
DataInput di = dataInputList[i];
file1.WriteLine("EFIN: "+di.getEFIN()+" StatusCode: "+di.getStatusCode()+" StatusDate: "+di.getStatusDate());
}
}
for (int i = 0; i >= dataInputList.Count; i++)
看来你的比较倒退了,我的朋友。应该是:
for (int i = 0; i < dataInputList.Count; i++)
我还要删除 =
,因为计数是 non-zero,并且 i
从 0
string path = @"C:\GIT\ELF\csharp\examples\EROIRSImport_sln\EROIRSImport\EROIRSImport\List.txt";
var lines = dataInputList.Select(di => $"EFIN: {di.GetEFIN()}\tStatusCode: {di.getStatusCode()}\tStatusDate: {di.getStatusDate()}");
File.WriteAllLines(path, lines);