2012-06-28 5 views
-1

내가 다음 코드를 사용하여 txt 파일에서 일부 텍스트 읽기 위해 노력하고 무시 다음 txt 파일이 일부 빈 줄과 줄 바꿈을 가지고줄 바꿈과 빈 줄

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

을하지만,이 코드는 모든 줄 바꿈을 무시하고 txt 파일의 빈 줄. 문제를 해결하는 방법을 제안 하시겠습니까?

답변

2

무시하지 않고 메일 본문에 추가하지 마십시오.

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