c# - 代码在运行多次后切断字符串

标签 c# string text-files streamwriter

这段代码循环运行。第 38 次运行后,打印到文本文件的字符串在第二个“M”后立即截断,甚至不打印逗号,然后停止打印所有内容并结束。

这可能是什么原因造成的?

private static void LogPayment(CDefeasancePayment paymentToLog, System.IO.StreamWriter outfile)
{
    string line = "AddDefeasancePayment(DateTime.Parse(\"" + paymentToLog.PaymentDate.ToShortDateString() +
                  "\"), " + paymentToLog.Interest +
                  "M, " + paymentToLog.Principal + "M, DateTime.Parse(\"" +
                  paymentToLog.StripDate.ToShortDateString() + "\"), " + paymentToLog.StripPrice +
                  "M);\n";
    outfile.Write(line);
}

最佳答案

确保您已刷新outfile 缓冲区。

关于c# - 代码在运行多次后切断字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4380846/

相关文章:

c# - 如何在一个界面中使用多个部分asp.net core 6?

c# - string.Format 输入字符串的格式不正确,因为带有大括号的字符串已经作为 C# 格式的一部分

c# - 将 ASP.NET GridView 控件绑定(bind)到字符串数组

c# - 在 UntyWebGl 中保存帧

java - 如何读取、处理和打印文本文件中的数据?

c++ - 从文件中读取第 11 列数字并取平均值?(c++)

java - 如何读取作为命令参数的文本文件(字符串)的第一行(在Java中使用eclipse)

Javascript 等价于 python 的 .format()

java - 检查空字符串 null 吗?

linux - fgrep 和egrep ?