C# 忽略换行符和空行

C# 忽略换行符和空行,c#,asp.net,C#,Asp.net,我正试图用以下代码从txt文件中读取一些文本: using (StreamReader sr = File.OpenText(System.IO.Path.GetFullPath("OrderEmailBody.txt"))) { String input; while ((input = sr.ReadLine()) != null) { emailBody += input; }

我正试图用以下代码从txt文件中读取一些文本:

  using (StreamReader sr = 
                 File.OpenText(System.IO.Path.GetFullPath("OrderEmailBody.txt")))
  {
      String input;
      while ((input = sr.ReadLine()) != null)
      {
          emailBody += input;
      }
}

txt文件有一些空行和换行符,但此代码忽略txt文件中的所有换行符和空行。请建议如何修复它?

它不会忽略它们,只是不会将它们添加到邮件正文中

emailBody += input + Environment.NewLine;
  using (StreamReader sr = 
             File.OpenText(System.IO.Path.GetFullPath("OrderEmailBody.txt")))
  {
      String input;
      while ((input = sr.ReadLine()) != null)
      {
          emailBody += input;
          email += Environment.NewLine;
      }
  }