예제 #1
0
        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

                    }
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: Wargog/MakeBoot
 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);
             }
         }
     }
 }
예제 #3
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);
     }
 }
예제 #4
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);
                }
            }
        }