예제 #1
0
        /* Extract all of the files to be passed to the FileManipulation Class */
        public string ExtractAllFiles()
        {
            SeperateByFileType();
            FileManipulation FM = new FileManipulation();
            /* goes through all of the lists and executes a certain extraction function based on that specific list */

            for (int i = 0; i < TypesList.Length; i++)
            {

                for (int j = 0; j < TypesList[i].Count; j++)
                {

                    switch (i)
                    {
                        case (int)Files.Rar:
                            ExtractRarFiles(TypesList[i][j]);
                            break;

                        case (int)Files.SevenZip:
                            ExtractZipFiles(TypesList[i][j]);
                            break;

                        case (int)Files.Zip:
                            ExtractZipFiles(TypesList[i][j]);
                            break;

                    }
                }

            }

            /* Move everything into another directory (Probably want to redo this)  */

            FM.CreateMainDirectory();
            string MainDirectoryPath = FM.MainDirPath;

            foreach (string ExtractedDir in ExtractedDirectories)
            {
                DirectoryInfo DirectoryInfo = new DirectoryInfo(ExtractedDir);
                try
                {
                    Directory.Move(ExtractedDir, Path.Combine(MainDirectoryPath, DirectoryInfo.Name));
                }
                catch (Exception)
                {

                }

            }

            OutputPath = MainDirectoryPath;
            return MainDirectoryPath;
        }
예제 #2
0
        /* extracts .7z files */
        private void ExtractSevZFiles(string FilePath)
        {
            FileManipulation FileMan = new FileManipulation();

               string PathStub = "";
               PathStub = FileMan.RenameDirectory(PathStub);
               string FinalPath = FilePath + PathStub;

               // SevenZipFile ZipExtract = new SevenZipFile()
        }
예제 #3
0
        /* extracts .zip files */
        private void ExtractZipFiles(string FilePath)
        {
            FileManipulation FileMover = new FileManipulation();

               string PathStub =  "";
               PathStub = FileMover.RenameDirectory(PathStub);

               FileInfo FileInPath = new FileInfo(FilePath); // used to get the name and directory of the target file

               string FinalPath = FileInPath.DirectoryName + @"\" + FileInPath.Name + PathStub ; // the directory of the target file
                                                                                             // the name + the stub of the target file
                                                                                            // used to create a new directory with the file

               ZipFile.ExtractToDirectory(FilePath, FinalPath);

               ExtractedDirectories.Add(FinalPath);
        }
예제 #4
0
        /* extracts .rar files */
        private void ExtractRarFiles(string FilePath)
        {
            FileManipulation FileMover = new FileManipulation(); // used to obtain and set various values based on the working directory

               string PathStub = "";
               PathStub = FileMover.RenameDirectory(PathStub); //  PathStub = "_Extracted"

               string FullPath = FilePath + PathStub; // the file path with the new name ( target directory )

               RarArchive ExtractorRar = RarArchive.Open(FilePath); // open an extractor to begin extracting files

               //extracts and moves files
               foreach (RarArchiveEntry entry in ExtractorRar.Entries)
               {
             string NewDirectory = Path.Combine(FullPath, entry.FilePath); // creates the path for a New target directory
             entry.WriteToDirectory(NewDirectory);  //move the fiels oto the newely created directory
               }

               ExtractedDirectories.Add(FullPath); // creates a list of extracted directories so we can move them all to a single folder.
        }