我想做一个上传,但他要求的就是上传RAR文件后,自动解压成文件夹或文件,这样可以吗.谢谢大家帮忙啊

解决方案 »

  1.   

    关键在于你有执行文件的权限吗??可以用WINRAR设定自动解压缩。
      

  2.   

    我写过一个类似的,不过因为是在局域网里面,所以权限的问题好解决,上传之后只要
    ProcessStartInfo p = new ProcessStartInfo();
    p.FileName = "winrar";
    p.WindowStyle = ProcessWindowStyle.Normal  ;
    p.Arguments=" a -r 路径" + DateTime.Now.ToString("yyyyMMdd") + ".rar 路径";
    Process proc =Process.Start(p);
    就可以了。也许这个思路对你有帮助。
      

  3.   

    你可以 调用winrar的组件 里面有方法的
      

  4.   

    我知道怎么解压缩.zip文件:
    using System;
    using System.Text;
    using System.Collections;
    using System.IO;
    using System.Diagnostics;
    using System.Runtime.Serialization.Formatters.Binary;
    using System.Data;using ICSharpCode.SharpZipLib.BZip2;
    using ICSharpCode.SharpZipLib.Zip;
    using ICSharpCode.SharpZipLib.Zip.Compression;
    using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
    using ICSharpCode.SharpZipLib.GZip;
    namespace MyWinzip
    {
    /// <summary>
    /// Class1 的摘要说明。
    /// </summary>
    public class UnZipClass
    {
    public void UnZip(string[] args)
    {
    ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
      
    ZipEntry theEntry;
    while ((theEntry = s.GetNextEntry()) != null) 
    {
       
    string directoryName = Path.GetDirectoryName(args[1]);
    string fileName      = Path.GetFileName(theEntry.Name);
       
    //生成解压目录
    Directory.CreateDirectory(directoryName);
       
    if (fileName != String.Empty) 
    {   
    //解压文件到指定的目录
    string path=args[1]+"\\"+theEntry.Name;
    FileStream streamWriter = File.Create(path);
        
    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();
    }
    }
    }
      

  5.   

    使用上面的类:
    this.openFileDialog1.ShowDialog();
                string filename=this.openFileDialog1.FileName;//待解压的文件
    int i=filename.LastIndexOf(".");
    string filepath=filename.Substring(0,i)+"\\";//解压后放置的目标目录 string []FileProperties=new string[2];
    FileProperties[0]=filename;
    FileProperties[1]=filepath;
    UnZipClass UnZc=new UnZipClass();
    UnZc.UnZip(FileProperties);