上传一个解压包后自动解压到某个位置,然后根据解压包根目录下文件的个数向数据库中插入记录,比如说有三个文件就插三条记录。(根目录下都是.sw1或.sw2文件)以前用那种多个文件上传的时候是通过上传文件的个数来确定插入数据库记录的条数。

解决方案 »

  1.   

    可以使用.Net 自带的解压缩类,但是好像不支持 WinRaR 压缩格式....
      

  2.   

    http://www.pconline.com.cn/pcedu/empolder/net/0605/797105.html
      

  3.   

    if(File1.PostedFile.FileName!=""&&File1.PostedFile.ContentLength>0)
    {
    if(("application/x-zip-compressed||application/octet-stream||application/x-gzip-compressed").IndexOf(File1.PostedFile.ContentType.Trim())<0)
    {
    Response.Write("<script> alert('您上传的软件必须为压缩文件!!!');</script>");
    return;
    }if(File1.PostedFile.ContentLength>200*1024*1024)
    {
    Response.Write("<script> alert('您上传的软件太大!!!');</script>");
    return;
    }
    name1=System.Guid.NewGuid().ToString();
    aa=File1.PostedFile.FileName;
    aa=aa.Substring(aa.LastIndexOf('\\')+1);
    string ext=System.IO.Path.GetExtension(File1.PostedFile.FileName).ToLower().Trim();
    name1=name1+ext;
    string bb=System.Configuration.ConfigurationSettings.AppSettings["UpLoadRoot"].ToString();
    File1.PostedFile.SaveAs(bb+name1);
    }
      

  4.   

    不知道是不是你想要的:
    private string up_load(HtmlInputFile f)
    {
    string name=null; if(f.Value.Trim().Length>0)
    {
    string filename=System.IO.Path.GetFileName(f.PostedFile.FileName);
    filename=filename.Replace(" ","-");

    string path=System.Configuration.ConfigurationSettings.AppSettings["UpLoadRoot"].ToString(); try
    {
    f.PostedFile.SaveAs(path+filename);
    name=filename;
    }
    catch
    {
    name=null;
    this.Response.Write("<script>alert('上传文件失敗');</script>");
    }
    }
    return name;
    } private bool check_file(HtmlInputFile f)

    bool b=false; string filename=System.IO.Path.GetFileName(f.PostedFile.FileName);
    string path=System.Configuration.ConfigurationSettings.AppSettings["UpLoadRoot"].ToString();
    if(File.Exists(path+filename))
    {
    b=true;
    } return b;
    }
    private void Button1_Click(object sender, System.EventArgs e)
    {
    string filename=null;
    if(File1.Value.Trim().Length>0)
    {
    if(check_file(File1))
    {
    this.Response.Write("<script>alert('文件名重覆,请修改文件名!')</script>");
    return;
    } filename=up_load(File1);
    }...(File2,File3)

    if(filename!=null)
    {}
      

  5.   

    直接调用rar dll就可以
      

  6.   

    通过SharpZipLib解压文件到文件夹,再遍历文件夹获取文件数
    string []FileProperties=new string[2];
    FileProperties[0]=strPath; //待解压的文件
    FileProperties[1]=strPath+@"\"; //解压后放置的目标目录
    UnZip(FileProperties);public void UnZip(string[] args)
    {
    ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
      
    ZipEntry theEntry = s.GetNextEntry();
    while ((theEntry = s.GetNextEntry()) != null) 
    {
       
    string directoryName = Path.GetDirectoryName(args[1]);
    string fileName      = Path.GetFileName(theEntry.Name);
       
    //生成解压目录
    Directory.CreateDirectory(directoryName);
       
    if (fileName != String.Empty) 
    {   
    //解压文件到指定的目录
    FileStream streamWriter = File.Create(args[1]+theEntry.Name);
        
    int size = 2048;
    byte[] data = new byte[2048];
    while (true) 
    {
    size = s.Read(data, 0, data.Length);
    if (size > 0) 
    {
    streamWriter.Write(data, 0, size);

    else 
    {
    break;
    }
    }
    streamWriter.Close();
    }
    }
    s.Close();
    }
    }
      

  7.   

        /// <summary>
        /// 调用RAR进程进行解压缩
        /// </summary>
        /// rar <命令> -<开关 1> -<开关 N> "<压缩文件>" "<解压路径>"
        /// x  用绝对路径解压缩文件
        /// o+ 覆盖已存在文件
        /// r 递归子目录
        public void UnRAR(string rarDir, string rarName, string unRarDir){
            Process process = new Process();
            process.StartInfo.FileName = "winrar.exe";
            process.StartInfo.CreateNoWindow = false;
            process.StartInfo.Arguments = "x -o+ -r \"" + rarName + "\" \"" + unRarDir + "\"";
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.StartInfo.WorkingDirectory = rarDir;
            process.Start();
            process.WaitForExit();
            process.Close();
        }