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>");
}
}
本文介绍了一个使用C#实现的简单方法,该方法用于从指定文件路径读取文件的全部内容,并将其显示在一个文本框中。如果在读取过程中发生异常,会弹出警告消息。
905

被折叠的 条评论
为什么被折叠?



