asp.net中上传多个文件

dalaifu 2009-10-19 03:52:30
谁能给点多文件上传的例子,谢谢啦
...全文
67 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xhlwx 2009-12-31
  • 打赏
  • 举报
回复
happy664618843 2009-11-03
  • 打赏
  • 举报
回复
   public static string  CreateUploadFile(string FileOlder)
{

HttpPostedFile postedfile;

HttpFileCollection file1 = HttpContext.Current.Request.Files;

System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch();
st.Start();
for (int i = 0; i < file1.Count; i++)
{
postedfile = HttpContext.Current.Request.Files[i];

//获取文件的扩展名
FileEx=Path.GetExtension(postedfile.FileName);

//追加文件名


////定义文件名以时间命名加上文件扩展名
string saveFile= DateTime.Now.ToString("yyyyMMddHHmmss")+st.ElapsedTicks.ToString() + FileEx;
sb.Append(saveFile);
sb.Append(",");

//保存文件
postedfile.SaveAs(HttpContext.Current.Server.MapPath(FileOlder + "/") + saveFile);

}
if(sb.Length>0)
sb.Remove(sb.Length-1, 1);

st.Stop();

return sb.ToString();

}

1,978

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧