1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116:
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO;
namespace LAN_Party_Game_Installer { public partial class Form4 : Form { int maxbytes = 0; int copied = 0; int total = 0;
public Form4() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { { string quell = textBox1.Text; string user = textBox2.Text; Copy1(@quell + ":\\LAN-Party-Games\\Userdata\\Command & Conquer 3 Tiberium Wars", @"C:\users\" + @user + "\\Appdata\\Roaming\\Command & Conquer 3 Tiberium Wars");
MessageBox.Show("Done"); button2.Visible = true;
} } public void Copy1(string sourceDirectory, string targetDirectory) {
DirectoryInfo diSource = new DirectoryInfo(sourceDirectory); DirectoryInfo diTarget = new DirectoryInfo(targetDirectory); GetSize(diSource, diTarget); maxbytes = maxbytes / 1024;
progressBar1.Maximum = maxbytes; CopyAll(diSource, diTarget); } public void CopyAll(DirectoryInfo source, DirectoryInfo target) {
if (Directory.Exists(target.FullName) == false) { Directory.CreateDirectory(target.FullName); } foreach (FileInfo fi in source.GetFiles()) {
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), true);
total += (int)fi.Length;
copied += (int)fi.Length; copied /= 1024; progressBar1.Step = copied;
progressBar1.PerformStep(); label1.Text = (total / 1048576).ToString() + "MB of " + (maxbytes / 1024).ToString() + "MB copied";
label1.Refresh(); } foreach (DirectoryInfo diSourceSubDir in source.GetDirectories()) {
DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name); CopyAll(diSourceSubDir, nextTargetSubDir); } }
public void GetSize(DirectoryInfo source, DirectoryInfo target) {
if (Directory.Exists(target.FullName) == false) { Directory.CreateDirectory(target.FullName); } foreach (FileInfo fi in source.GetFiles()) { maxbytes += (int)fi.Length;
} foreach (DirectoryInfo diSourceSubDir in source.GetDirectories()) { DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name); GetSize(diSourceSubDir, nextTargetSubDir);
} }
private void button2_Click(object sender, EventArgs e) { Form5 form5 = new Form5(); form5.Show(); Hide(); } } } |