阅读217 返回首页    go 阿里云 go 技术社区[云栖]


在ASP.NET中实现多文件上传

一下为代码片段:


privateBooleanSaveFiles()
{
//得到File表单元素
HttpFileCollectionfiles=HttpContext.Current.Request.Files;
try
{
for(intintCount=0;intCount<files.Count;intCount++)
{

HttpPostedFilepostedFile=files[intCount];
stringfileName,fileExtension;
//获得文件名字
fileName=System.IO.Path.GetFileName(postedFile.FileName);
if(fileName!="")
{
//获得文件名扩展
fileExtension=System.IO.Path.GetExtension(fileName);
//可根据不同的扩展名字,保存文件到不同的文件夹
//注意:可能要修改你的文件夹的匿名写入权限。
postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("upFiles/")+fileName);
}
}
returntrue;
}
catch(System.ExceptionEx)
{
returnfalse;
}
}

最后更新:2017-04-02 00:06:36

  上一篇:go 通过ASP.net程序创建域帐户故障
  下一篇:go 如何显示在线人数和所在位置