猪二哥的小园子儿
小园子儿里的猪二哥
  public bool UnRAR(string destPath, string rarfilePath)
        {
            try
            {
                // destPath = @"E:\youxiaodi\temp"; //目标位置
                // rarfilePath = @"E:\youxiaodi\temp\gif.rar"; //被解压文件
                //组合出需要shell的完整格式
                string shellArguments = string.Format("x -o+ \"{0}\" \"{1}\\\"",
                    rarfilePath, destPath);
                //用Process调用
                using (Process unrar = new Process())
                {
                    unrar.StartInfo.FileName = @"C:\Program Files\WinRAR\UnRAR.exe";
                    unrar.StartInfo.Arguments = shellArguments;
                    //隐藏rar本身的窗口
                    unrar.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    unrar.Start();
                    //等待解压完成
                    unrar.WaitForExit();
                    unrar.Close();
                }
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }

 

posted on 2014-05-07 17:03  猪小娣  阅读(946)  评论(0编辑  收藏  举报