using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FileIO
{
    
public partial class uploadFile : System.Web.UI.Page
    {
        
protected void Page_Load(object sender, EventArgs e)
        {

        }

        
protected void Button1_Click(object sender, EventArgs e)
        {
            
string path = Server.MapPath("~/upload/");
            HttpFileCollection uploadFiles 
= Request.Files;
            
for (int i = 0; i < uploadFiles.Count; i++)
            {
                HttpPostedFile userPostedFile
=uploadFiles[i];
                
try
                {
                    
if (userPostedFile.ContentLength > 0)
                    {
                        userPostedFile.SaveAs(path 
+ userPostedFile.FileName);
                    }
                }
                
catch (Exception)
                {
                    
                    
throw;
                }
            }
           
        }
    }
}

相关文章: