System.IO.FileNotFoundException 问题
在做上传文件的页面时,本地调试是没有问题,一旦放到服务器空间里调试就会出现System.IO.FileNotFoundException错误!
could not find file 'c:\windows\system32\inetsrv\MER_308440183980006_20080725.txt'
我上传文件的代码如下:
string fileName = FileUpload1.PostedFile.FileName;
StreamReader TxtReader = new StreamReader(fileName, System.Text.Encoding.GetEncoding(936));
SqlConnection conn = Connection.Conn();
string savePath = Server.MapPath("~/Upload");
//如果不存在Upload路径则创建
if (!System.IO.Directory.Exists(savePath))
{
System.IO.Directory.CreateDirectory(savePath);
}
savePath = savePath + "\\" + FileUpload1.FileName;
//保存文件
FileUpload1.SaveAs(savePath);