Code
string uploadPath = Server.MapPath(Request.ApplicationPath + "/Upload/" + SysUser.UserName);
if (Directory.Exists(uploadPath) == false)
{
Directory.CreateDirectory(uploadPath);
}
for (int j = 0; j < Request.Files.Count; j++)
{
HttpPostedFile uploadFile = Request.Files[j];
if (uploadFile.ContentLength > 0)
{
uploadFile.SaveAs(Path.Combine(uploadPath, uploadFile.FileName));
}
}
string uploadPath = Server.MapPath(Request.ApplicationPath + "/Upload/" + SysUser.UserName);
if (Directory.Exists(uploadPath) == false)
{
Directory.CreateDirectory(uploadPath);
}
for (int j = 0; j < Request.Files.Count; j++)
{
HttpPostedFile uploadFile = Request.Files[j];
if (uploadFile.ContentLength > 0)
{
uploadFile.SaveAs(Path.Combine(uploadPath, uploadFile.FileName));
}
}
分类:
.net,C#小技巧,代码片断
本文转自Sam Lin博客博客园博客,原文链接:http://www.cnblogs.com/samlin/archive/2009/02/27/Upload-File-By-UserName.html,如需转载请自行联系原作者