帮我看一下,为什么我上传文件到虚拟服务器会找不到路径啊
富贵连连 2010-09-20 10:58:15 int fileSize=this.upfile.PostedFile.ContentLength;//得到上传文件大小
string name=this.upfile.PostedFile.FileName;//文件名
string type=name.Substring(name.LastIndexOf(".")+1);
FileStream fs=File.OpenRead(name);
byte[] content=new byte[fs.Length];
fs.Read(content,0,content.Length);
fs.Close();
if (type == "txt" || type == "sql" )
{
string filenname = "sql";
if(!Directory.Exists(Server.MapPath("~/file/")))
{
Directory.CreateDirectory(Server.MapPath("~/file/"));
}
string filepath = HttpContext.Current.Request.MapPath("~/file/" + filenname + "." + type);//当前路径
this.Label2.Text = filepath;
//判断是否有文件存在
if(System.IO.File.Exists(filepath))
{
File.Delete(filepath);
}
this.upfile.PostedFile.SaveAs(filepath);