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); } var test = Dinfo.GetFiles(); foreach (DiscFileInfo finfo in test) { using (Stream FileStr = finfo.OpenRead()) { using (FileStream Fs = File.Create(RootPath + "\\" + finfo.Name)) { Progress_Bar.Increment(1 / test.Length); Progress_Number.Text = Progress_Bar.Value.ToString() + " %"; Progress_Number.Refresh(); FileStr.CopyTo(Fs, 8 * 1024); } } } }
private void Timer1_Tick(object sender, EventArgs e) { Progress_Bar.Minimum = 0; Progress_Bar.Maximum = 100; Progress_Bar.Enabled = true; Progress_Timer.Enabled = true; string extractTo = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Directory.CreateDirectory(extractTo); if (Progress_Bar.Value == 0) { string s = IntegrateOS.Temporary_I.locatie; ExtractISO(s, extractTo); Progress_Bar.Value = 100; Progress_Number.Text = Progress_Bar.Value.ToString() + " %"; Progress_Number.Refresh(); Progress_Timer.Stop(); } if (Progress_Bar.Value == 100) { var extensions = new List <string> { ".swm", ".wim", ".esd" }; string[] files = Directory.GetFiles(extractTo, "*.*", SearchOption.AllDirectories) .Where(f => extensions.IndexOf(Path.GetExtension(f)) >= 0).ToArray(); if (files.Length == 0) { MessageBox.Show("It isn't an official Windows iso!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Progress_Timer.Enabled = false; Progress_Timer.Stop(); Moving.Form(this, new Select_installation(Location)); } else { Moving.Form(this, new Select_Image_File(files, Location)); } } }