コード例 #1
0
 public void BrowseHier(RPFLib.Common.Directory dir, RPFLib.Common.Directory rDir)
 {
     foreach (RPFLib.Common.fileSystemObject d in dir)
     {
         if (d.IsDirectory)
         {
             BrowseHier(d as RPFLib.Common.Directory, rDir);
             System.IO.Directory.CreateDirectory(extrPath + "\\" + rDir.Name + "\\" + d.FullName.Replace(rDir.FullName + "\\", ""));
         }
         else
         {
             currentCount++;
             RPFLib.Common.File file = d as RPFLib.Common.File;
             byte[]             data = file.GetData(false);
             if (!(System.IO.Directory.Exists(extrPath + "\\" + rDir.Name + "\\" + file.FullName.Replace(rDir.FullName + "\\", "").Replace(file.Name, ""))))
             {
                 System.IO.Directory.CreateDirectory(extrPath + "\\" + rDir.Name + "\\" + file.FullName.Replace(rDir.FullName + "\\", "").Replace(file.Name, ""));
             }
             System.IO.File.WriteAllBytes(extrPath + "\\" + rDir.Name + "\\" + file.FullName.Replace(rDir.FullName + "\\", ""), data);
         }
     }
 }
コード例 #2
0
ファイル: RPFviewer.cs プロジェクト: reditec/RDR-Explorer
        private void backgroundWorker4_DoWork(object sender, DoWorkEventArgs e)
        {
            if (backButton.GetCurrentParent().InvokeRequired)
                backButton.GetCurrentParent().Invoke((MethodInvoker)(() => backButton.Enabled = false));
            else
                backButton.Enabled = false;
            if (extrButton.GetCurrentParent().InvokeRequired)
                extrButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrButton.Enabled = false));
            else
                extrButton.Enabled = false;
            if (extrAllButton.GetCurrentParent().InvokeRequired)
                extrAllButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrAllButton.Enabled = false));
            else
                extrAllButton.Enabled = false;
            if (uncompressButton.GetCurrentParent().InvokeRequired)
                uncompressButton.GetCurrentParent().Invoke((MethodInvoker)(() => uncompressButton.Enabled = false));
            else
                uncompressButton.Enabled = false;

            using (var sfrm = new FolderBrowserDialog())
            {
                int countOfItems = 0;
                if (listView1.InvokeRequired)
                    listView1.Invoke((MethodInvoker)(() => countOfItems = listView1.SelectedItems.Count));
                else
                    countOfItems = listView1.SelectedItems.Count;
                if(countOfItems == 1)
                {
                    bool isDir = false;
                    foreach (RPFLib.Common.fileSystemObject fEntry in masterlist)
                    {
                        string fSelectedString = "";
                        if (this.InvokeRequired)
                        {
                            this.Invoke((MethodInvoker)(() =>
                            {
                                fSelectedString = listView1.SelectedItems[0].Text;
                            }));
                        }
                        else
                        {
                            fSelectedString = listView1.SelectedItems[0].Text;
                        }
                        if (fEntry.Name == fSelectedString)
                        {
                            isDir = fEntry.IsDirectory;
                        }
                    }
                    if (!(isDir))
                    {
                        DialogResult testthing = DialogResult.None;
                        if (this.InvokeRequired)
                            this.Invoke((MethodInvoker)(() => testthing = sfrm.ShowDialog(this)));
                        else
                            testthing = sfrm.ShowDialog(this);
                        if (testthing == DialogResult.OK)
                        {
                            List<fileSystemObject> objectList = new List<fileSystemObject>();
                            if (!(System.IO.Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted")))
                            {
                                System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted");
                            }

                            RPFLib.Common.File file = new RPFLib.Common.File();
                            foreach (RPFLib.Common.fileSystemObject entry in masterlist)
                            {
                                string selectedString = "";
                                if (this.InvokeRequired)
                                {
                                    this.Invoke((MethodInvoker)(() =>
                                    {
                                        selectedString = listView1.SelectedItems[0].Text;
                                    }));
                                }
                                else
                                {
                                    selectedString = listView1.SelectedItems[0].Text;
                                }
                                if (entry.Name == selectedString && !(entry.IsDirectory))
                                {
                                    file = entry as RPFLib.Common.File;
                                    byte[] data = file.GetData(false);
                                    System.IO.File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted\\" + file.Name, data);
                                    ProcessStartInfo startInfo = new ProcessStartInfo("RSCUnpacker.exe");
                                    startInfo.Arguments = "\"" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted\\" + file.Name + "\" -Xbox360";
                                    startInfo.UseShellExecute = false;
                                    startInfo.CreateNoWindow = true;
                                    Process Extractor = Process.Start(startInfo);
                                    Extractor.WaitForExit();
                                    System.IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted\\" + file.Name);
                                    System.IO.DirectoryInfo myDir = new System.IO.DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted\\");
                                    foreach (System.IO.FileInfo myFile in myDir.GetFiles())
                                    {
                                        if (System.IO.File.Exists(sfrm.SelectedPath + "\\" + myFile.Name))
                                        {
                                            System.IO.File.Delete(sfrm.SelectedPath + "\\" + myFile.Name);
                                        }
                                        myFile.MoveTo(sfrm.SelectedPath + "\\" + myFile.Name);
                                    }
                                }
                                else
                                {

                                }
                            }
                        }
                    }

                    }
                }
            if (backButton.GetCurrentParent().InvokeRequired)
                backButton.GetCurrentParent().Invoke((MethodInvoker)(() => backButton.Enabled = true));
            else
                backButton.Enabled = true;
            if (extrButton.GetCurrentParent().InvokeRequired)
                extrButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrButton.Enabled = true));
            else
                extrButton.Enabled = true;
            if (extrAllButton.GetCurrentParent().InvokeRequired)
                extrAllButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrAllButton.Enabled = true));
            else
                extrAllButton.Enabled = true;
            if (uncompressButton.GetCurrentParent().InvokeRequired)
                uncompressButton.GetCurrentParent().Invoke((MethodInvoker)(() => uncompressButton.Enabled = true));
            else
                uncompressButton.Enabled = true;
        }
コード例 #3
0
        private void backgroundWorker4_DoWork(object sender, DoWorkEventArgs e)
        {
            if (backButton.GetCurrentParent().InvokeRequired)
            {
                backButton.GetCurrentParent().Invoke((MethodInvoker)(() => backButton.Enabled = false));
            }
            else
            {
                backButton.Enabled = false;
            }
            if (extrButton.GetCurrentParent().InvokeRequired)
            {
                extrButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrButton.Enabled = false));
            }
            else
            {
                extrButton.Enabled = false;
            }
            if (extrAllButton.GetCurrentParent().InvokeRequired)
            {
                extrAllButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrAllButton.Enabled = false));
            }
            else
            {
                extrAllButton.Enabled = false;
            }
            if (uncompressButton.GetCurrentParent().InvokeRequired)
            {
                uncompressButton.GetCurrentParent().Invoke((MethodInvoker)(() => uncompressButton.Enabled = false));
            }
            else
            {
                uncompressButton.Enabled = false;
            }

            using (var sfrm = new FolderBrowserDialog())
            {
                int countOfItems = 0;
                if (listView1.InvokeRequired)
                {
                    listView1.Invoke((MethodInvoker)(() => countOfItems = listView1.SelectedItems.Count));
                }
                else
                {
                    countOfItems = listView1.SelectedItems.Count;
                }
                if (countOfItems == 1)
                {
                    bool isDir = false;
                    foreach (RPFLib.Common.fileSystemObject fEntry in masterlist)
                    {
                        string fSelectedString = "";
                        if (this.InvokeRequired)
                        {
                            this.Invoke((MethodInvoker)(() =>
                            {
                                fSelectedString = listView1.SelectedItems[0].Text;
                            }));
                        }
                        else
                        {
                            fSelectedString = listView1.SelectedItems[0].Text;
                        }
                        if (fEntry.Name == fSelectedString)
                        {
                            isDir = fEntry.IsDirectory;
                        }
                    }
                    if (!(isDir))
                    {
                        DialogResult testthing = DialogResult.None;
                        if (this.InvokeRequired)
                        {
                            this.Invoke((MethodInvoker)(() => testthing = sfrm.ShowDialog(this)));
                        }
                        else
                        {
                            testthing = sfrm.ShowDialog(this);
                        }
                        if (testthing == DialogResult.OK)
                        {
                            List <fileSystemObject> objectList = new List <fileSystemObject>();
                            if (!(System.IO.Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted")))
                            {
                                System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted");
                            }

                            RPFLib.Common.File file = new RPFLib.Common.File();
                            foreach (RPFLib.Common.fileSystemObject entry in masterlist)
                            {
                                string selectedString = "";
                                if (this.InvokeRequired)
                                {
                                    this.Invoke((MethodInvoker)(() =>
                                    {
                                        selectedString = listView1.SelectedItems[0].Text;
                                    }));
                                }
                                else
                                {
                                    selectedString = listView1.SelectedItems[0].Text;
                                }
                                if (entry.Name == selectedString && !(entry.IsDirectory))
                                {
                                    file = entry as RPFLib.Common.File;
                                    byte[] data = file.GetData(false);
                                    System.IO.File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted\\" + file.Name, data);
                                    ProcessStartInfo startInfo = new ProcessStartInfo("RSCUnpacker.exe");
                                    startInfo.Arguments       = "\"" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted\\" + file.Name + "\" -Xbox360";
                                    startInfo.UseShellExecute = false;
                                    startInfo.CreateNoWindow  = true;
                                    Process Extractor = Process.Start(startInfo);
                                    Extractor.WaitForExit();
                                    System.IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted\\" + file.Name);
                                    System.IO.DirectoryInfo myDir = new System.IO.DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Reditec\\RDR Explorer\\extracted\\");
                                    foreach (System.IO.FileInfo myFile in myDir.GetFiles())
                                    {
                                        if (System.IO.File.Exists(sfrm.SelectedPath + "\\" + myFile.Name))
                                        {
                                            System.IO.File.Delete(sfrm.SelectedPath + "\\" + myFile.Name);
                                        }
                                        myFile.MoveTo(sfrm.SelectedPath + "\\" + myFile.Name);
                                    }
                                }
                                else
                                {
                                }
                            }
                        }
                    }
                }
            }
            if (backButton.GetCurrentParent().InvokeRequired)
            {
                backButton.GetCurrentParent().Invoke((MethodInvoker)(() => backButton.Enabled = true));
            }
            else
            {
                backButton.Enabled = true;
            }
            if (extrButton.GetCurrentParent().InvokeRequired)
            {
                extrButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrButton.Enabled = true));
            }
            else
            {
                extrButton.Enabled = true;
            }
            if (extrAllButton.GetCurrentParent().InvokeRequired)
            {
                extrAllButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrAllButton.Enabled = true));
            }
            else
            {
                extrAllButton.Enabled = true;
            }
            if (uncompressButton.GetCurrentParent().InvokeRequired)
            {
                uncompressButton.GetCurrentParent().Invoke((MethodInvoker)(() => uncompressButton.Enabled = true));
            }
            else
            {
                uncompressButton.Enabled = true;
            }
        }
コード例 #4
0
        private void backgroundWorker3_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (backButton.GetCurrentParent().InvokeRequired)
                {
                    backButton.GetCurrentParent().Invoke((MethodInvoker)(() => backButton.Enabled = false));
                }
                else
                {
                    backButton.Enabled = false;
                }
                if (extrButton.GetCurrentParent().InvokeRequired)
                {
                    extrButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrButton.Enabled = false));
                }
                else
                {
                    extrButton.Enabled = false;
                }
                if (extrAllButton.GetCurrentParent().InvokeRequired)
                {
                    extrAllButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrAllButton.Enabled = false));
                }
                else
                {
                    extrAllButton.Enabled = false;
                }
                if (uncompressButton.GetCurrentParent().InvokeRequired)
                {
                    uncompressButton.GetCurrentParent().Invoke((MethodInvoker)(() => uncompressButton.Enabled = false));
                }
                else
                {
                    uncompressButton.Enabled = false;
                }
                using (FolderBrowserDialog sfrm = new FolderBrowserDialog())
                {
                    DialogResult testthing = DialogResult.None;
                    if (this.InvokeRequired)
                    {
                        this.Invoke((MethodInvoker)(() => testthing = sfrm.ShowDialog(this)));
                    }
                    else
                    {
                        testthing = sfrm.ShowDialog(this);
                    }
                    if (testthing == DialogResult.OK)
                    {
                        extrPath     = sfrm.SelectedPath;
                        countOfFiles = 0;
                        Task taskA = Task.Factory.StartNew(() =>
                        {
                            foreach (RPFLib.Common.fileSystemObject entry in masterlist)
                            {
                                if (entry.IsDirectory)
                                {
                                    RPFLib.Common.Directory dir = entry as RPFLib.Common.Directory;
                                    CountFilesInHier(dir);
                                }
                                else
                                {
                                    countOfFiles++;
                                }
                            }
                        });
                        taskA.Wait();

                        if (toolStripProgressBar1.GetCurrentParent().InvokeRequired)
                        {
                            toolStripProgressBar1.GetCurrentParent().Invoke((MethodInvoker)(() =>
                            {
                                timer1.Enabled = true;
                                timer1.Start();
                            }));
                        }
                        else
                        {
                            timer1.Enabled = true;
                            timer1.Start();
                        }

                        Task taskB = Task.Factory.StartNew(() =>
                        {
                            foreach (RPFLib.Common.fileSystemObject entry in masterlist)
                            {
                                if (entry.IsDirectory)
                                {
                                    RPFLib.Common.Directory dir = entry as RPFLib.Common.Directory;
                                    System.IO.Directory.CreateDirectory(extrPath + "\\" + dir.Name);
                                    BrowseHier(dir, dir);
                                }
                                else
                                {
                                    RPFLib.Common.File file = entry as RPFLib.Common.File;
                                    byte[] data             = file.GetData(false);
                                    System.IO.File.WriteAllBytes(sfrm.SelectedPath + "\\" + file.Name, data);
                                }
                            }
                        });
                        taskB.Wait();

                        if (toolStripProgressBar1.GetCurrentParent().InvokeRequired)
                        {
                            toolStripProgressBar1.GetCurrentParent().Invoke((MethodInvoker)(() =>
                            {
                                timer1.Stop();
                                timer1.Enabled = false;
                                toolStripProgressBar1.Value = 0;
                            }));
                        }
                        else
                        {
                            timer1.Stop();
                            timer1.Enabled = false;
                            toolStripProgressBar1.Value = 0;
                        }
                    }
                }
                if (backButton.GetCurrentParent().InvokeRequired)
                {
                    backButton.GetCurrentParent().Invoke((MethodInvoker)(() => backButton.Enabled = true));
                }
                else
                {
                    backButton.Enabled = true;
                }
                if (extrButton.GetCurrentParent().InvokeRequired)
                {
                    extrButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrButton.Enabled = true));
                }
                else
                {
                    extrButton.Enabled = true;
                }
                if (extrAllButton.GetCurrentParent().InvokeRequired)
                {
                    extrAllButton.GetCurrentParent().Invoke((MethodInvoker)(() => extrAllButton.Enabled = true));
                }
                else
                {
                    extrAllButton.Enabled = true;
                }
                if (uncompressButton.GetCurrentParent().InvokeRequired)
                {
                    uncompressButton.GetCurrentParent().Invoke((MethodInvoker)(() => uncompressButton.Enabled = true));
                }
                else
                {
                    uncompressButton.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                Application.Exit();
            }
        }