日期:2014-05-18  浏览次数:20363 次

asp.net fileupload控件上传文件
使用fileupload上传文件,文件的保存路径如下:
 string savepath = Server.MapPath("~/upfile") + "/" + username + "/";
  if (!Directory.Exists(savepath))
  Directory.CreateDirectory(savepath);
 FileUpload1.PostedFile.SaveAs(savepath);
但是提示System.IO.DirectoryNotFoundException: 未能找到路径“D:\istudy\upfile\teacherli\”的一部分。
teacherli为username的一个具体实例,实际上,文件夹中已经自动新建了这个文件夹,为什么会提示这个错误呢
请高手指教

------解决方案--------------------
string savepath = Server.MapPath("~/upfile") + "/" + username + "/";
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
 FileUpload1.PostedFile.SaveAs(savepath+“你的文件名”);