Skip to content

Instantly share code, notes, and snippets.

@capablaza
Created August 18, 2014 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capablaza/9afc0186a24a68e1fba6 to your computer and use it in GitHub Desktop.
Save capablaza/9afc0186a24a68e1fba6 to your computer and use it in GitHub Desktop.
Read file with c# .
/// <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