File Reader sample

private void GetFileContents(String FileName)
    {
        try
        {
            FileInfo inf = new FileInfo(FileName);
            StreamReader rd = new StreamReader(inf.OpenRead());
            tb_Context.Text = rd.ReadToEnd();
            rd.Close();
                }
        catch (Exception e)
        {
            Response.Write("<script>alert('"+e.Message+"')</script>");
        }
}

 

原文地址:https://www.cnblogs.com/Winston/p/1026479.html