Created
August 18, 2014 15:30
-
-
Save capablaza/9afc0186a24a68e1fba6 to your computer and use it in GitHub Desktop.
Read file with c# .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// This class allows read a file than simple way. | |
/// </summary> | |
public class FileRead | |
{ | |
/// <summary> | |
/// Routine that return a StringBuilder with the content that was read | |
/// </summary> | |
/// <param name="pathFile">Filename to read.(Include full path)</param> | |
/// <returns></returns> | |
public static StringBuilder readFile(string pathFile) | |
{ | |
string lineRead = string.Empty; | |
StringBuilder content = new StringBuilder(); | |
using (StreamReader file = new StreamReader(pathFile)) | |
{ | |
#region Read File | |
while (lineRead != null) | |
{ | |
lineRead = file.ReadLine(); | |
if (lineRead != null) | |
{ | |
content.Append(lineRead); | |
} | |
} | |
#endregion Read File | |
} | |
return content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment