public void ExtractDirectory(DiscDirectoryInfo Dinfo, string RootPath, string PathinISO)
        {
            if (!string.IsNullOrWhiteSpace(PathinISO))
            {
                PathinISO += "\\" + Dinfo.Name;
            }
            RootPath += "\\" + Dinfo.Name;
            AppendDirectory(RootPath);
            Form1 form1 = new Form1();
            foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories())
            {
                ExtractDirectory(dinfo, RootPath, PathinISO);
            }
            foreach (DiscFileInfo finfo in Dinfo.GetFiles())
            {
                using (Stream FileStr = finfo.OpenRead())
                {
                    using (FileStream Fs = File.Create(RootPath + "\\" + finfo.Name)) // Here you can Set the BufferSize Also e.g. File.Create(RootPath + "\\" + finfo.Name, 4 * 1024)
                    {
                        FileStr.CopyTo(Fs, 4 * 1024); // Buffer Size is 4 * 1024 but you can modify it in your code as per your need

                    }
                }
            }
        }
Exemple #2
0
 private static void ExtractDirectory(DiscDirectoryInfo Dinfo, string RootPath, string PathinISO)
 {
     if (!string.IsNullOrWhiteSpace(PathinISO))
     {
         PathinISO += "\\" + Dinfo.Name;
     }
     RootPath += "\\" + Dinfo.Name;
     AppendDirectory(RootPath);
     foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories())
     {
         ExtractDirectory(dinfo, RootPath, PathinISO);
     }
     foreach (DiscFileInfo finfo in Dinfo.GetFiles())
     {
         using (Stream FileStr = finfo.OpenRead())
         {
             using (FileStream Fs = File.Create(RootPath + "\\" + finfo.Name))
             {
                 FileStr.CopyTo(Fs, 4 * 1024);
             }
         }
     }
 }
Exemple #3
0
        private static Task CompTree(DiscDirectoryInfo A, DiscDirectoryInfo B, DiscDirectoryInfo Out,
            CopyQueue WriteQueue, ComparisonStyle Style = ComparisonStyle.DateTimeOnly)
        {
            if (WriteQueue == null) throw new ArgumentNullException("WriteQueue");
            List<Task> tasks = new List<Task>();

            DiscFileSystem Alock = A.FileSystem;
            DiscFileSystem Block = B.FileSystem;
            DiscFileSystem Olock = Out.FileSystem;

            ParallelQuery<DiscFileInfo> BFiles;
            lock(Block)
                BFiles = B.GetFiles("*.*", SearchOption.AllDirectories).ToArray().AsParallel();
            BFiles = BFiles.Where(file =>
                                  !ExcludeFiles.Contains(file.FullName.ToUpperInvariant())
                                 ).AsParallel();
            BFiles = ExclusionRules.Aggregate(BFiles, (current, rule) => current.Where(file => !rule.IsMatch(file.FullName)));

                BFiles = BFiles.Where(file =>
                    {
                        DiscFileInfo Atmp;
                        lock (Alock)
                            Atmp = Alock.GetFileInfo(file.FullName);
                        return !CompareFile(Atmp, file, Style);
                    }).ToArray().AsParallel();

            foreach (var file in BFiles)
            {
                DiscFileInfo outFile;
                lock (Olock)
                    outFile = Out.FileSystem.GetFileInfo(Path.Combine(Out.FullName, file.FullName));
                lock (Alock)
                WriteQueue.Add(file, outFile, Alock.GetFileInfo(file.FullName));
            }

            return Task.Factory.StartNew(() => Task.WaitAll(tasks.ToArray()), TaskCreationOptions.AttachedToParent);
        }
Exemple #4
0
 private static void ShowDir(DiscDirectoryInfo dirInfo, int indent)
 {
     Console.WriteLine("{0}{1,-50} [{2}]", new String(' ', indent), CleanName(dirInfo.FullName), dirInfo.CreationTimeUtc);
     foreach (DiscDirectoryInfo subDir in dirInfo.GetDirectories())
     {
         ShowDir(subDir, indent + 0);
     }
     foreach (DiscFileInfo file in dirInfo.GetFiles())
     {
         Console.WriteLine("{0}{1,-50} [{2}]", new String(' ', indent), CleanName(file.FullName), file.CreationTimeUtc);
     }
 }
Exemple #5
0
        private void CopyDirectory(DiscDirectoryInfo source, DirectoryInfo target, bool recurse)
        {
            if (recurse)
            {
                foreach (var childDiscDirectory in source.GetDirectories())
                {
                    DirectoryInfo childDirectory = target.CreateSubdirectory(childDiscDirectory.Name);
                    CopyDirectory(childDiscDirectory, childDirectory, recurse);
                }
            }

            Console.WriteLine("{0}", source.Name);

            foreach (var childFile in source.GetFiles())
            {
                using (Stream sourceStream = childFile.OpenRead())
                using (Stream targetStream = File.OpenWrite(Path.Combine(target.FullName, childFile.Name)))
                {
                    sourceStream.CopyTo(targetStream);
                }
            }
        }