Example #1
0
        public RarOpener(BinaryData inputData)
        {
			m_rar = new Chilkat.Rar();

            m_fileName = Path.GetTempFileName();
            inputData.Save(m_fileName);
            if (!m_rar.Open(m_fileName))
            {
                throw new Exception(m_rar.LastErrorText);
            }
        }
        /*
         * /// <summary>
         * /// 需要安装Haozip,支持各种格式解压
         * /// </summary>
         * /// <param name="inPath"></param>
         * /// <param name="outPath"></param>
         * public static void HaoUnZip(string inPath, string outPath)
         * {
         *  try
         *  {
         *      if (File.Exists(inPath))
         *      {
         *          Process process = new Process();
         *          process.StartInfo.FileName = haozipPath;
         *          process.StartInfo.Arguments = " x " + inPath + " -yo" + outPath;
         *          // process.Exited += new EventHandler(myProcess_Exited);
         *          process.Start();
         *      }
         *  }catch(Exception ex)
         *  {
         *      log.ErrorFormat("文件 {0} 解压出错,异常信息: {1}", inPath, ex.Message);
         *  }
         * }
         *
         *
         * /// <summary>
         * /// 需要安装Haozip,默认以zip格式压缩;另外支持 7z, tar,但不推荐
         * /// </summary>
         * /// <param name="inPath"></param>
         * /// <param name="outPath"></param>
         * public static void HaoZip(string inPath, string outPath)
         * {
         *  try
         *  {
         *      if (Directory.Exists(inPath))
         *      {
         *          Process process = new Process();
         *          process.StartInfo.FileName = haozipPath;
         *          process.StartInfo.Arguments = " a -tzip -r " + outPath + " " + inPath;
         *          process.Start();
         *      }
         *  }catch(Exception ex)
         *  {
         *      log.ErrorFormat("目录 {0} 压缩出错,异常信息: {1}", inPath, ex.Message);
         *  }
         * }
         */
        #endregion

        #region RAR解压
        /// <summary>
        /// 解压 RAR
        /// </summary>
        /// <param name="source">rar源文件,支持中文</param>
        /// <param name="dest">解压到目录,暂不支持中文</param>
        public static void UnRar(string source, string dest)
        {
            if (!File.Exists(source))
            {
                return;
            }
            if (!Directory.Exists(dest))
            {
                Directory.CreateDirectory(dest);
            }

            Chilkat.Rar rar = new Chilkat.Rar();
            rar.Open(source);
            rar.Unrar(dest);
        }
        public void openRAR(string filename)
        {
            curpagenum = 0;
            dir        = new ArrayList();
            Chilkat.Rar rar = new Chilkat.Rar();
            rar.Open(filename);
            totalpages = 0;
            if (System.IO.Directory.Exists(bpath))
            {
                DeleteDirectory(bpath);
            }
            Random rand = new Random();
            int    r    = rand.Next();

            path      = bpath + r.ToString();
            thumbPath = path + "\\Thumbs";
            System.IO.Directory.CreateDirectory(path);
            rar.Unrar(path);

            string[] dirs = Directory.GetDirectories(path);
            if (dirs.GetLength(0) == 0)
            {
                string[] filelist = Directory.GetFiles(path);
                foreach (string p in filelist)
                {
                    if (System.IO.Path.GetExtension(p) == ".jpg" || System.IO.Path.GetExtension(p) == ".png")
                    {
                        dir.Add(p);
                        totalpages++;
                    }
                }
            }
            else
            {
                string[] filelist = Directory.GetFiles(dirs[0]);
                foreach (string p in filelist)
                {
                    if (System.IO.Path.GetExtension(p) == ".jpg" || System.IO.Path.GetExtension(p) == ".png")
                    {
                        dir.Add(p);
                        totalpages++;
                    }
                }
            }
            rar.Close();
        }
Example #4
0
        void downloadUpdate()
        {
            using (WebClient Client = new WebClient())
            {
                Client.DownloadFile("https://iranapp.org/bongah/bongah.rar", "update.rar");
            }

            if (Directory.Exists(Application.StartupPath + "\\update") == false)
            {
                Directory.CreateDirectory(Application.StartupPath + "\\update");
            }

            rar1.Open(Application.StartupPath + "\\update.rar");
            rar1.Unrar(Application.StartupPath + "\\update");

            MessageBox.Show("نرم افزار با موفقیت بروز رسانی شد\r\nبرای اعمال بروز رسانی،نرم افزار مجددا راه اندازی میشود", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
            CancelEventArgs e = new CancelEventArgs(false);

            Application.Exit(e);

            System.Diagnostics.Process.Start(Application.StartupPath + "\\update.bat");
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //qua lo devo scompattare !!
            textBoxOutput.AppendText("Uncompressing...\n");
            try
            {
                UnZipFiles(downloadPath + "\\TrinityCore.zip", downloadPath, null, true);
            }
            catch ( FileNotFoundException ) {
                textBoxOutput.AppendText("Trinity ZIP not found n!\n");

            }
            Chilkat.Rar rar = new Chilkat.Rar();
            if (rar.Open(downloadPath + "\\FullDB.rar"))
            {
                rar.Unrar(downloadPath);
                textBoxOutput.AppendText("Unrar the main DB!\n");
                File.Delete(downloadPath + "\\FullDB.rar");
            }
            else
             textBoxOutput.AppendText("Unrar main DB FAILED !!\n"+rar.LastErrorText);

            rar.Close();

            textBoxOutput.AppendText("Done!\n");
        }