大字符串似乎包装时,我不希望它

问题描述:

我在我的c#应用程序中创建一个长字符串。我希望它保持一行,因为这些是用户选择在数据库中更新的字段的标题。 该字符串将用于日志文件中。大字符串似乎包装时,我不希望它

当我选择所有要更新的字段时,看起来字符串很长,以便显示在一行中并自动包装。

我很困惑,因为文本文件应该能够处理任何长度的字符串(内存允许),而不包装。

看来,一旦字符串获得超过约1050个字符,它会自动换行。

我的代码如下:

private void UpdateCustomer(string pCurrentFileName, ref StringBuilder log, string date, ref string directoryPath, ref string logFilePath) 
    { 
     // set the logfile paths for customer update 
     directoryPath = Path.Combine(pLogFilePath, "CustomerUpdate_Log_" + date.Replace("/", "").Replace(" ", "").Replace(":", "")); 
     logFilePath = Path.Combine(directoryPath, "CustomerUpdate.log"); 
     DataSet customerUpdateDataSet = new CustomerUpdateValidator().ImportCustomersForUpdateFromExcelFileToDataSet(pCurrentFileName); 

     log.Append("-------------------------------------------------------------------------" + "\r\n"); 
     log.Append("Bulk Maintenance Log: Customer Updatess" + "\r\n"); 
     log.Append("-------------------------------------------------------------------------" + "\r\n"); 
     log.Append(date + "\r\n\r\n"); 
     log.Append("Total number of Customer to be updated: " + (customerUpdateDataSet.Tables["CustomerData"].Rows.Count - 2).ToString() + "\r\n\r\n"); 
     log.Append("Data to be Inserted" + "\r\n"); 
     log.Append("-".PadRight(300, '-') + "\r\n\r\n\r\n"); 

     StringBuilder header = new StringBuilder("Row".PadRight(10, ' ') + "\t"); 
     header.Append("URN".PadRight(40, ' ') + "\t"); 

     int count = 0; 
     // for each row in the grid view 
     for (int i = 0; i < this.gridView1.DataRowCount; i++) 
     { 
      // if the value is checked 
      if (Convert.ToBoolean(this.gridView1.GetRowCellValue(i, "CheckMarkSelection"))) 
      { 
       // get the fields from the checked column 
       string baxiDescription = this.gridView1.GetRowCellValue(i, "SimpleName").ToString(); 
       int size = getSizeFromType(this.gridView1.GetRowCellValue(i, "Type").ToString()); 
       header.Append(baxiDescription.PadRight(size, ' ') + "\t"); 
       count = i; 
      } 
     } 

     header.Append("Result".PadRight(10, ' ') + "\t"); 
     header.Append("Reason".PadRight(30, ' ') + "\t"); 

     log.Append(header.ToString() + "\r\n"); 
     log.Append(new StringBuilder("-".PadRight(header.Length + 60, '-') + "\r\n")); 
    } 

任何想法,为什么发生这种情况?

My DataSetWrapped LogFile

问候,

伊恩

+5

听起来像它可能是一个客户端问题,而不是数据的一部分。你在展示什么? –

+0

与Jon一致,在十六进制查看器或显示CR-LF的东西中查看,看看是否真的存在换行符。 – Vman

+0

@Jon Skeet Im在memoedit devexpress控件中显示它。它也被保存为一个文本文件,该文件与备忘录编辑完全相同的字符串处。 我注意到,在调试过程中,它也在监视窗口中做同样的事情 –

看来,因为我我生成的字符串保存到一个txt文件,然后打开文本文件在我的日志文件浏览器的问题是与.txt文件相关,而不是我的代码