Get File contents into String
CodeKeep C# Feed Maggio 7th, 2008
Description: This code is used to read contents of a given file.
Link: http://www.codekeep.net/snippets/adf5054b-78fb-449f-8423-b693cb6b34fb.aspx
public static string GetFileContents(string FileName)
{
StreamReader sr = null;
string FileContents = null;
try
{
FileStream fs = new FileStream(FileName, FileMode.Open,
FileAccess.Read);
sr = new StreamReader(fs);
FileContents = sr.ReadToEnd();
}
finally
{
if (sr != null)
sr.Close();
}
return FileContents;
}






