如何读取本地上的txt文档,求助!
protected void btnOpenfile_Click(object sender, EventArgs e)
{
string path = Server.MapPath(@"d:\\newFile.txt");
StreamReader read = new StreamReader(path);
while (read.Peek() >= 0)
{
//逐行读取数据
Console.WriteLine(read);
string lineStr = read.ReadLine();
//
}
}
我这样写能读取吗?我运行的时候“d:\\newFile.txt”不是有效的虚拟路径”。
我的思路是这样的,在界面上有个按钮,和一个文本框,如何点击按钮,把d盘下的txt文档内容显示在文本框里面。
求老师帮忙下,谢谢!!!