根据用户名上传文件到用户名的目录下

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));
            }
        }
posted @ 2009-02-27 10:37  Sam Lin  阅读(521)  评论(0编辑  收藏  举报