Sunday, May 6, 2012

.NET C# Read from a file

public static string ReadFromFile(string fileName)
{
    string ret = "";
    System.IO.StreamReader sr;
    try
    {
        sr = new System.IO.StreamReader(fileName);           
        ret = sr.ReadToEnd();
        sr.Close();
        return ret;
    }
    catch{ return null; }
}

No comments:

Post a Comment