最近,我们的ASP.NET项目遇到了多文件上传的问题.我们是这样处理的.

一 客户端必须装Framework (我也没办法啦,装就装吧)
二 新建一个winform项目,

编写客户端程序

 1 private void button1_Click(object sender, System.EventArgs e)
 2         {
 3             System.Net.WebClient client = new System.Net.WebClient();
 4 
 5             forint i = 0; i < listBox1.Items.Count; i++ )
 6             {
 7                 try
 8                 {
 9                     client.UploadFile( "http://10.6.11.39/UploadWebForm/RecieveUploadRequest.aspx""POST", listBox1.Items[i].ToString() );
10                     label1.Text = "上传完毕";
11                 }
12                 catch( Exception exc )
13                 {
14                     MessageBox.Show( exc.Message );
15                 }
16             }
17         }

三 编写服务器aspx,用于接收客户端post

1         private void Page_Load(object sender, System.EventArgs e)
2         {
3             foreach( String str in Request.Files.AllKeys )
4             {
5                 HttpPostedFile file = Request.Files[ str ];
6                 file.SaveAs( "C:\\download\\" + file.FileName );
7             }
8         }

四 在浏览器里运行客户端
打开IE,运行你的winform.exe(在虚拟目录里)就OK了


总结:其实这是一个简单的SmartClient的部署方式,可以通过IE执行.如果大家对在ASP.NET里多文件上传还有比较好的方法,请回复,小弟先谢谢了

相关文章:

  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2021-07-25
猜你喜欢
  • 2021-11-29
  • 2021-11-22
  • 2022-03-05
  • 2021-07-23
  • 2021-11-06
  • 2021-06-11
相关资源
相似解决方案