diff --git a/NUS Downloader/Form1.Designer.cs b/NUS Downloader/Form1.Designer.cs index cafe790..bdc4d90 100644 --- a/NUS Downloader/Form1.Designer.cs +++ b/NUS Downloader/Form1.Designer.cs @@ -65,25 +65,17 @@ this.PALMassUpdate = new System.Windows.Forms.ToolStripMenuItem(); this.NTSCMassUpdate = new System.Windows.Forms.ToolStripMenuItem(); this.KoreaMassUpdate = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.updateDatabaseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.button3 = new System.Windows.Forms.Button(); this.extrasStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.loadInfoFromTMDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.emulateUpdate = new System.Windows.Forms.ToolStripMenuItem(); - this.uSANTSCToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.europePALToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.japanNTSCJToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.koreaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.proxySettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); - this.loadNUSScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.getCommonKeyMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.commonKeykeybinToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.koreanKeykkeybinToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.updateDatabaseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveaswadbox = new System.Windows.Forms.CheckBox(); this.deletecontentsbox = new System.Windows.Forms.CheckBox(); this.proxyBox = new System.Windows.Forms.GroupBox(); @@ -100,13 +92,22 @@ this.consoleCBox = new System.Windows.Forms.ComboBox(); this.scriptsbutton = new System.Windows.Forms.Button(); this.scriptsStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.loadNUSScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.emulateUpdate = new System.Windows.Forms.ToolStripMenuItem(); + this.uSANTSCToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.europePALToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.japanNTSCJToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.koreaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.titleversion = new wmgCMS.WaterMarkTextBox(); this.titleidbox = new wmgCMS.WaterMarkTextBox(); this.dlprogress = new wyDay.Controls.Windows7ProgressBar(); + this.scriptsMainMenuEntry = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.databaseStrip.SuspendLayout(); this.extrasStrip.SuspendLayout(); this.proxyBox.SuspendLayout(); this.ProxyVerifyBox.SuspendLayout(); + this.scriptsStrip.SuspendLayout(); this.SuspendLayout(); // // Extrasbtn @@ -242,10 +243,12 @@ this.WiiWareMenuList, this.toolStripSeparator1, this.RegionCodesList, - this.MassUpdateList}); + this.MassUpdateList, + this.toolStripSeparator4, + this.updateDatabaseToolStripMenuItem}); this.databaseStrip.Name = "databaseStrip"; this.databaseStrip.ShowItemToolTips = false; - this.databaseStrip.Size = new System.Drawing.Size(167, 142); + this.databaseStrip.Size = new System.Drawing.Size(167, 170); // // SystemMenuList // @@ -397,6 +400,19 @@ this.KoreaMassUpdate.Size = new System.Drawing.Size(104, 22); this.KoreaMassUpdate.Text = "Korea"; // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(163, 6); + // + // updateDatabaseToolStripMenuItem + // + this.updateDatabaseToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.database_save; + this.updateDatabaseToolStripMenuItem.Name = "updateDatabaseToolStripMenuItem"; + this.updateDatabaseToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.updateDatabaseToolStripMenuItem.Text = "Update Database"; + this.updateDatabaseToolStripMenuItem.Click += new System.EventHandler(this.updateDatabaseToolStripMenuItem_Click); + // // button3 // this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Popup; @@ -414,98 +430,37 @@ this.extrasStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.loadInfoFromTMDToolStripMenuItem, this.toolStripSeparator3, - this.emulateUpdate, - this.toolStripSeparator4, this.proxySettingsToolStripMenuItem, this.toolStripSeparator6, - this.loadNUSScriptToolStripMenuItem, - this.toolStripSeparator7, - this.getCommonKeyMenuItem, - this.toolStripSeparator2, - this.updateDatabaseToolStripMenuItem}); + this.getCommonKeyMenuItem}); this.extrasStrip.Name = "extrasStrip"; - this.extrasStrip.Size = new System.Drawing.Size(220, 166); + this.extrasStrip.Size = new System.Drawing.Size(183, 82); // // loadInfoFromTMDToolStripMenuItem // this.loadInfoFromTMDToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.page_white_magnify; this.loadInfoFromTMDToolStripMenuItem.Name = "loadInfoFromTMDToolStripMenuItem"; - this.loadInfoFromTMDToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.loadInfoFromTMDToolStripMenuItem.Size = new System.Drawing.Size(182, 22); this.loadInfoFromTMDToolStripMenuItem.Text = "Load Info from TMD"; this.loadInfoFromTMDToolStripMenuItem.Click += new System.EventHandler(this.loadInfoFromTMDToolStripMenuItem_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(216, 6); - // - // emulateUpdate - // - this.emulateUpdate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.uSANTSCToolStripMenuItem, - this.europePALToolStripMenuItem, - this.japanNTSCJToolStripMenuItem, - this.koreaToolStripMenuItem}); - this.emulateUpdate.Image = global::NUS_Downloader.Properties.Resources.server_connect; - this.emulateUpdate.Name = "emulateUpdate"; - this.emulateUpdate.Size = new System.Drawing.Size(219, 22); - this.emulateUpdate.Text = "Emulate Wii System Update"; - this.emulateUpdate.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.emulateUpdate_DropDownItemClicked); - // - // uSANTSCToolStripMenuItem - // - this.uSANTSCToolStripMenuItem.Name = "uSANTSCToolStripMenuItem"; - this.uSANTSCToolStripMenuItem.Size = new System.Drawing.Size(117, 22); - this.uSANTSCToolStripMenuItem.Text = "USA"; - // - // europePALToolStripMenuItem - // - this.europePALToolStripMenuItem.Name = "europePALToolStripMenuItem"; - this.europePALToolStripMenuItem.Size = new System.Drawing.Size(117, 22); - this.europePALToolStripMenuItem.Text = "EUROPE"; - // - // japanNTSCJToolStripMenuItem - // - this.japanNTSCJToolStripMenuItem.Name = "japanNTSCJToolStripMenuItem"; - this.japanNTSCJToolStripMenuItem.Size = new System.Drawing.Size(117, 22); - this.japanNTSCJToolStripMenuItem.Text = "JAPAN"; - // - // koreaToolStripMenuItem - // - this.koreaToolStripMenuItem.Name = "koreaToolStripMenuItem"; - this.koreaToolStripMenuItem.Size = new System.Drawing.Size(117, 22); - this.koreaToolStripMenuItem.Text = "KOREA"; - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(216, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(179, 6); // // proxySettingsToolStripMenuItem // this.proxySettingsToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.server_link; this.proxySettingsToolStripMenuItem.Name = "proxySettingsToolStripMenuItem"; - this.proxySettingsToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.proxySettingsToolStripMenuItem.Size = new System.Drawing.Size(182, 22); this.proxySettingsToolStripMenuItem.Text = "Proxy Settings"; this.proxySettingsToolStripMenuItem.Click += new System.EventHandler(this.proxySettingsToolStripMenuItem_Click); // // toolStripSeparator6 // this.toolStripSeparator6.Name = "toolStripSeparator6"; - this.toolStripSeparator6.Size = new System.Drawing.Size(216, 6); - // - // loadNUSScriptToolStripMenuItem - // - this.loadNUSScriptToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.script_go; - this.loadNUSScriptToolStripMenuItem.Name = "loadNUSScriptToolStripMenuItem"; - this.loadNUSScriptToolStripMenuItem.Size = new System.Drawing.Size(219, 22); - this.loadNUSScriptToolStripMenuItem.Text = "Load NUS Script"; - this.loadNUSScriptToolStripMenuItem.Click += new System.EventHandler(this.loadNUSScriptToolStripMenuItem_Click); - // - // toolStripSeparator7 - // - this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(216, 6); + this.toolStripSeparator6.Size = new System.Drawing.Size(179, 6); // // getCommonKeyMenuItem // @@ -514,7 +469,7 @@ this.koreanKeykkeybinToolStripMenuItem}); this.getCommonKeyMenuItem.Image = global::NUS_Downloader.Properties.Resources.key; this.getCommonKeyMenuItem.Name = "getCommonKeyMenuItem"; - this.getCommonKeyMenuItem.Size = new System.Drawing.Size(219, 22); + this.getCommonKeyMenuItem.Size = new System.Drawing.Size(182, 22); this.getCommonKeyMenuItem.Text = "Retrieve Key"; // // commonKeykeybinToolStripMenuItem @@ -531,19 +486,6 @@ this.koreanKeykkeybinToolStripMenuItem.Text = "Korean Key (kkey.bin)"; this.koreanKeykkeybinToolStripMenuItem.Click += new System.EventHandler(this.koreanKeykkeybinToolStripMenuItem_Click); // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(216, 6); - // - // updateDatabaseToolStripMenuItem - // - this.updateDatabaseToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.database_save; - this.updateDatabaseToolStripMenuItem.Name = "updateDatabaseToolStripMenuItem"; - this.updateDatabaseToolStripMenuItem.Size = new System.Drawing.Size(219, 22); - this.updateDatabaseToolStripMenuItem.Text = "Update Database"; - this.updateDatabaseToolStripMenuItem.Click += new System.EventHandler(this.updateDatabaseToolStripMenuItem_Click); - // // saveaswadbox // this.saveaswadbox.AutoSize = true; @@ -709,9 +651,59 @@ // // scriptsStrip // + this.scriptsStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.scriptsMainMenuEntry, + this.loadNUSScriptToolStripMenuItem, + this.toolStripSeparator2, + this.emulateUpdate}); this.scriptsStrip.Name = "scriptsStrip"; this.scriptsStrip.ShowItemToolTips = false; - this.scriptsStrip.Size = new System.Drawing.Size(61, 4); + this.scriptsStrip.Size = new System.Drawing.Size(220, 76); + // + // loadNUSScriptToolStripMenuItem + // + this.loadNUSScriptToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.script_go; + this.loadNUSScriptToolStripMenuItem.Name = "loadNUSScriptToolStripMenuItem"; + this.loadNUSScriptToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.loadNUSScriptToolStripMenuItem.Text = "Load NUS Script"; + this.loadNUSScriptToolStripMenuItem.Click += new System.EventHandler(this.loadNUSScriptToolStripMenuItem_Click); + // + // emulateUpdate + // + this.emulateUpdate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.uSANTSCToolStripMenuItem, + this.europePALToolStripMenuItem, + this.japanNTSCJToolStripMenuItem, + this.koreaToolStripMenuItem}); + this.emulateUpdate.Image = global::NUS_Downloader.Properties.Resources.server_connect; + this.emulateUpdate.Name = "emulateUpdate"; + this.emulateUpdate.Size = new System.Drawing.Size(219, 22); + this.emulateUpdate.Text = "Emulate Wii System Update"; + this.emulateUpdate.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.emulateUpdate_DropDownItemClicked); + // + // uSANTSCToolStripMenuItem + // + this.uSANTSCToolStripMenuItem.Name = "uSANTSCToolStripMenuItem"; + this.uSANTSCToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.uSANTSCToolStripMenuItem.Text = "USA"; + // + // europePALToolStripMenuItem + // + this.europePALToolStripMenuItem.Name = "europePALToolStripMenuItem"; + this.europePALToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.europePALToolStripMenuItem.Text = "EUROPE"; + // + // japanNTSCJToolStripMenuItem + // + this.japanNTSCJToolStripMenuItem.Name = "japanNTSCJToolStripMenuItem"; + this.japanNTSCJToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.japanNTSCJToolStripMenuItem.Text = "JAPAN"; + // + // koreaToolStripMenuItem + // + this.koreaToolStripMenuItem.Name = "koreaToolStripMenuItem"; + this.koreaToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.koreaToolStripMenuItem.Text = "KOREA"; // // titleversion // @@ -747,6 +739,18 @@ this.dlprogress.Size = new System.Drawing.Size(250, 15); this.dlprogress.TabIndex = 47; // + // scriptsMainMenuEntry + // + this.scriptsMainMenuEntry.Enabled = false; + this.scriptsMainMenuEntry.Name = "scriptsMainMenuEntry"; + this.scriptsMainMenuEntry.Size = new System.Drawing.Size(219, 22); + this.scriptsMainMenuEntry.Text = "Scripts\\"; + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(216, 6); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -787,6 +791,7 @@ this.proxyBox.PerformLayout(); this.ProxyVerifyBox.ResumeLayout(false); this.ProxyVerifyBox.PerformLayout(); + this.scriptsStrip.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -828,14 +833,8 @@ private System.Windows.Forms.ContextMenuStrip extrasStrip; private System.Windows.Forms.ToolStripMenuItem loadInfoFromTMDToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Windows.Forms.ToolStripMenuItem emulateUpdate; - private System.Windows.Forms.ToolStripMenuItem uSANTSCToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem europePALToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem japanNTSCJToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem koreaToolStripMenuItem; private System.Windows.Forms.CheckBox saveaswadbox; private System.Windows.Forms.CheckBox deletecontentsbox; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; private System.Windows.Forms.ToolStripMenuItem proxySettingsToolStripMenuItem; private System.Windows.Forms.GroupBox proxyBox; private System.Windows.Forms.TextBox ProxyUser; @@ -850,11 +849,7 @@ private System.Windows.Forms.TextBox ProxyPwdBox; private wyDay.Controls.Windows7ProgressBar dlprogress; private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; - private System.Windows.Forms.ToolStripMenuItem loadNUSScriptToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; private System.Windows.Forms.ToolStripMenuItem getCommonKeyMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripMenuItem updateDatabaseToolStripMenuItem; private System.Windows.Forms.ContextMenuStrip C64MenuListDrop; private System.Windows.Forms.ToolStripMenuItem MassUpdateList; private System.Windows.Forms.ToolStripMenuItem PALMassUpdate; @@ -867,6 +862,16 @@ private wmgCMS.WaterMarkTextBox titleversion; private System.Windows.Forms.Button scriptsbutton; private System.Windows.Forms.ContextMenuStrip scriptsStrip; + private System.Windows.Forms.ToolStripMenuItem loadNUSScriptToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem emulateUpdate; + private System.Windows.Forms.ToolStripMenuItem uSANTSCToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem europePALToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem japanNTSCJToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem koreaToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripMenuItem updateDatabaseToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem scriptsMainMenuEntry; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; } } diff --git a/NUS Downloader/Form1.cs b/NUS Downloader/Form1.cs index c17a8d3..a2c0986 100644 --- a/NUS Downloader/Form1.cs +++ b/NUS Downloader/Form1.cs @@ -9,7 +9,6 @@ using System.Text.RegularExpressions; using System.ComponentModel; using System.Threading; using System.Text; -using wyDay.Controls; using System.Diagnostics; @@ -20,6 +19,8 @@ namespace NUS_Downloader private const string WII_NUS_URL = "http://nus.cdn.shop.wii.com/ccs/download/"; private const string DSI_NUS_URL = "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/"; + private readonly string CURRENT_DIR = Directory.GetCurrentDirectory(); + // TODO: Always remember to change version! private string version = "v1.5a Beta"; private WebClient generalWC = new WebClient(); @@ -158,93 +159,11 @@ namespace NUS_Downloader scripter.DoWork += new DoWorkEventHandler(RunScript); scripter.RunWorkerAsync(); } - - - /* CLI MODE DEPRECATED... - // Vars - bool startnow = false; - bool endafter = false; - - // Fix'd - localuse.Checked = false; - - // Switch through arguments - for (int i = 0; i < args.Length; i++) - { - switch (args[i]) - { - case "-t": - if (args[i + 1].Length == 16) - titleidbox.Text = args[i + 1]; - else - { - WriteStatus("Title ID: Your Doing It Wrong (c)"); - WriteStatus("ex: -t 0000000100000002"); - } - break; - case "-v": - titleversion.Text = args[i + 1]; - break; - case "-s": - startnow = true; - break; - case "-close": - endafter = true; - break; - case "-d": - decryptbox.Checked = true; - break; - case "-ticket": - ignoreticket.Checked = true; - break; - case "-local": - localuse.Checked = true; - break; - case "-p": - packbox.Checked = true; - wadnamebox.Text = args[i + 1]; - break; - case "-dsi": - radioButton2.Checked = true; - break; - default: - break; - } - } - - // Start doing stuff... - if ((startnow) && (titleidbox.Text.Length != 0)) - { - // Prevent mass deletion - if ((titleidbox.Text == "") && (titleversion.Text == "")) - { - WriteStatus("Please enter SOME info..."); - return; - } - else - { - if (!statusbox.Lines[0].StartsWith(" ---")) - statusbox.Text = " --- " + titleidbox.Text + " ---"; - } - - // Running Downloads in background so no form freezing - NUSDownloader.RunWorkerAsync(); - } - - // Close if specified - while (NUSDownloader.IsBusy) - { - Thread.Sleep(1000); - } - if ((NUSDownloader.IsBusy == false) && (endafter == true)) - { - Application.Exit(); - } */ } private void Form1_Load(object sender, EventArgs e) { - this.Text = "NUSD - " + version + " - WB3000"; + this.Text = String.Format("NUSD - {0} - WB3000", version); ; this.Size = this.MinimumSize; consoleCBox.SelectedIndex = 0; } @@ -255,14 +174,8 @@ namespace NUS_Downloader /// private void BootChecks() { - // Directory stuff - string currentdir = Directory.GetCurrentDirectory(); - - //if (currentdir.EndsWith(Convert.ToString(Path.DirectorySeparatorChar.ToString())) == false) - //currentdir += Path.DirectorySeparatorChar.ToString(); - // Check for Wii common key bin file... - if (File.Exists(Path.Combine(currentdir, "key.bin")) == false) + if (File.Exists(Path.Combine(CURRENT_DIR, "key.bin")) == false) { WriteStatus("Common Key (key.bin) missing! Decryption disabled!"); WriteStatus(" - Try: Extras -> Retrieve Key -> Common Key"); @@ -282,34 +195,30 @@ namespace NUS_Downloader else { WriteStatus(" - Converting your key.bin file to the correct format..."); - // Directory stuff - //string keydir = Directory.GetCurrentDirectory(); - //if (!(keydir.EndsWith(Path.DirectorySeparatorChar.ToString())) || !(keydir.EndsWith(Path.AltDirectorySeparatorChar.ToString()))) - //keydir += Path.DirectorySeparatorChar.ToString(); - TextReader ckreader = new StreamReader(Path.Combine(currentdir, "key.bin")); + TextReader ckreader = new StreamReader(Path.Combine(CURRENT_DIR, "key.bin")); String ckashex = ckreader.ReadLine(); ckreader.Close(); - File.Delete(Path.Combine(currentdir, "key.bin")); + File.Delete(Path.Combine(CURRENT_DIR, "key.bin")); WriteCommonKey("key.bin", HexStringToByteArray(ckashex)); } } } // Check for Wii KOR common key bin file... - if (File.Exists(Path.Combine(currentdir, "kkey.bin")) == true) + if (File.Exists(Path.Combine(CURRENT_DIR, "kkey.bin")) == true) { WriteStatus("Korean Common Key detected."); } // Check for DSi common key bin file... - if (File.Exists(Path.Combine(currentdir, "dsikey.bin")) == true) + if (File.Exists(Path.Combine(CURRENT_DIR, "dsikey.bin")) == true) { WriteStatus("DSi Common Key detected."); dsidecrypt = true; } // Check for database.xml - if (File.Exists(Path.Combine(currentdir, "database.xml")) == false) + if (File.Exists(Path.Combine(CURRENT_DIR, "database.xml")) == false) { WriteStatus("Database.xml not found. Title database not usable!"); databaseButton.Visible = false; @@ -329,10 +238,10 @@ namespace NUS_Downloader } // Check for Proxy Settings file... - if (File.Exists(Path.Combine(currentdir, "proxy.txt")) == true) + if (File.Exists(Path.Combine(CURRENT_DIR, "proxy.txt")) == true) { WriteStatus("Proxy settings detected."); - string[] proxy_file = File.ReadAllLines(Path.Combine(currentdir, "proxy.txt")); + string[] proxy_file = File.ReadAllLines(Path.Combine(CURRENT_DIR, "proxy.txt")); proxy_url = proxy_file[0]; if (proxy_file.Length > 1) { @@ -880,13 +789,6 @@ namespace NUS_Downloader SetEnableforDownload(false); downloadstartbtn.Text = "Starting NUS Download!"; - // Current directory... - string currentdir = Directory.GetCurrentDirectory(); - - if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) || - !(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString()))) - currentdir += Path.DirectorySeparatorChar.ToString(); - // Prevent crossthread issues string titleid = titleidbox.Text; @@ -905,9 +807,9 @@ namespace NUS_Downloader // Get placement directory early... string titledirectory; if (titleversion.Text == "") - titledirectory = currentdir + titleid + Path.DirectorySeparatorChar.ToString(); + titledirectory = Path.Combine(CURRENT_DIR, titleid); else - titledirectory = currentdir + titleid + "v" + titleversion.Text + Path.DirectorySeparatorChar.ToString(); + titledirectory = Path.Combine(CURRENT_DIR, (titleid + "v" + titleversion.Text)); downloadstartbtn.Text = "Prerequisites: (0/2)"; @@ -975,7 +877,7 @@ namespace NUS_Downloader if (ticket_exists) { // Create ticket file holder - cetkbuf = FileLocationToByteArray(titledirectory + Path.DirectorySeparatorChar.ToString() + @"cetk"); + cetkbuf = FileLocationToByteArray(Path.Combine(titledirectory, "cetk")); // Obtain TitleKey titlekey = new byte[16]; @@ -1004,15 +906,15 @@ namespace NUS_Downloader if (cetkbuf[0x01F1] == 0x01) { WriteStatus("Key Type: Korean"); - keyBytes = LoadCommonKey(Path.DirectorySeparatorChar.ToString() + @"kkey.bin"); + keyBytes = LoadCommonKey("kkey.bin"); } else { WriteStatus("Key Type: Standard"); if (wiimode) - keyBytes = LoadCommonKey(Path.DirectorySeparatorChar.ToString() + @"key.bin"); + keyBytes = LoadCommonKey("key.bin"); else - keyBytes = LoadCommonKey(Path.DirectorySeparatorChar.ToString() + @"dsikey.bin"); + keyBytes = LoadCommonKey("dsikey.bin"); } initCrypt(iv, keyBytes); @@ -1023,7 +925,7 @@ namespace NUS_Downloader } // Read the tmd as a stream... - byte[] tmd = FileLocationToByteArray(titledirectory + tmdfull); + byte[] tmd = FileLocationToByteArray(Path.Combine(titledirectory, tmdfull)); if (ticket_exists == true) { @@ -1053,10 +955,10 @@ namespace NUS_Downloader WriteStatus("Requires: IOS" + sysversion); // Renaming would be ideal, but gives too many permission errors... - /*if ((currentdir + titleid + "v" + titleversion.Text + Path.DirectorySeparatorChar.ToString()) != titledirectory) + /*if ((CURRENT_DIR + titleid + "v" + titleversion.Text + Path.DirectorySeparatorChar.ToString()) != titledirectory) { - Directory.Move(titledirectory, currentdir + titleid + "v" + titleversion.Text + Path.DirectorySeparatorChar.ToString()); - titledirectory = currentdir + titleid + "v" + titleversion.Text + Path.DirectorySeparatorChar.ToString(); + Directory.Move(titledirectory, CURRENT_DIR + titleid + "v" + titleversion.Text + Path.DirectorySeparatorChar.ToString()); + titledirectory = CURRENT_DIR + titleid + "v" + titleversion.Text + Path.DirectorySeparatorChar.ToString(); } */ // Read Content #... @@ -1089,7 +991,7 @@ namespace NUS_Downloader try { // If it exists we leave it... - if ((localuse.Checked) && (File.Exists(titledirectory + tmdcontents[i]))) + if ((localuse.Checked) && (File.Exists(Path.Combine(titledirectory, tmdcontents[i])))) { WriteStatus("Leaving local " + tmdcontents[i] + "."); } @@ -1112,8 +1014,7 @@ namespace NUS_Downloader } // Progress reporting advances... - downloadstartbtn.Text = "Content: (" + (i + 1) + Path.AltDirectorySeparatorChar.ToString() + - contentstrnum + ")"; + downloadstartbtn.Text = String.Format("Content: ({0} / {1})", (i + 1), contentstrnum); currentcontentlocation += int.Parse(tmdsizes[i], System.Globalization.NumberStyles.HexNumber); // Decrypt stuff... @@ -1121,7 +1022,7 @@ namespace NUS_Downloader { // Create content file holder byte[] contbuf = - FileLocationToByteArray(titledirectory + Path.DirectorySeparatorChar.ToString() + tmdcontents[i]); + FileLocationToByteArray(Path.Combine(titledirectory, tmdcontents[i])); // IV (00+IDX+more000) byte[] iv = new byte[16]; @@ -1142,7 +1043,7 @@ namespace NUS_Downloader FileStream decfs = new FileStream( - titledirectory + Path.DirectorySeparatorChar.ToString() + tmdcontents[i] + ".app", + Path.Combine(titledirectory, (tmdcontents[i] + ".app")), FileMode.Create); decfs.Write(Decrypt(contbuf), 0, int.Parse(tmdsizes[i], System.Globalization.NumberStyles.HexNumber)); decfs.Close(); @@ -1194,19 +1095,12 @@ namespace NUS_Downloader /// private void CreateTitleDirectory() { - // Creates the directory for the downloaded title... - string currentdir = Directory.GetCurrentDirectory(); - if (currentdir.EndsWith(Convert.ToString(Path.DirectorySeparatorChar.ToString())) == false) - currentdir += Path.DirectorySeparatorChar.ToString(); - // Get placement directory early... string titledirectory; if (titleversion.Text == "") - titledirectory = Path.Combine(currentdir, titleidbox.Text + Path.DirectorySeparatorChar.ToString()); + titledirectory = Path.Combine(CURRENT_DIR, titleidbox.Text); else - titledirectory = Path.Combine(currentdir, - titleidbox.Text + "v" + titleversion.Text + - Path.DirectorySeparatorChar.ToString()); + titledirectory = Path.Combine(CURRENT_DIR, (titleidbox.Text + "v" + titleversion.Text)); // Keep local directory if present and checked out... if ((localuse.Checked) && (Directory.Exists(titledirectory))) @@ -1227,23 +1121,15 @@ namespace NUS_Downloader /// private void DeleteTitleDirectory() { - string currentdir = Directory.GetCurrentDirectory(); - if (currentdir.EndsWith(Convert.ToString(Path.DirectorySeparatorChar.ToString())) == false) - currentdir += Path.DirectorySeparatorChar.ToString(); - // Get placement directory early... string titledirectory; if (titleversion.Text == "") - titledirectory = Path.Combine(currentdir, titleidbox.Text + Path.DirectorySeparatorChar.ToString()); + titledirectory = Path.Combine(CURRENT_DIR, titleidbox.Text); else - titledirectory = Path.Combine(currentdir, - titleidbox.Text + "v" + titleversion.Text + - Path.DirectorySeparatorChar.ToString()); + titledirectory = Path.Combine(CURRENT_DIR, (titleidbox.Text + "v" + titleversion.Text)); if (Directory.Exists(titledirectory)) Directory.Delete(titledirectory, true); - - //Directory.CreateDirectory(currentdir + titleidbox.Text); } /// @@ -1260,9 +1146,9 @@ namespace NUS_Downloader // Create NUS URL... string nusfileurl; if (iswiititle) - nusfileurl = WII_NUS_URL + titleid + Path.AltDirectorySeparatorChar.ToString() + filename; + nusfileurl = CombinePaths(WII_NUS_URL, titleid, filename); else - nusfileurl = DSI_NUS_URL + titleid + Path.AltDirectorySeparatorChar.ToString() + filename; + nusfileurl = CombinePaths(DSI_NUS_URL, titleid, filename); WriteStatus("Grabbing " + filename + "..."); @@ -1271,7 +1157,7 @@ namespace NUS_Downloader statusbox.Text += " (" + Convert.ToString(sizeinbytes) + " bytes)"; // Download NUS file... - generalWC.DownloadFile(nusfileurl, placementdir + filename); + generalWC.DownloadFile(nusfileurl, Path.Combine(placementdir, filename)); } private void StatusChange(string status) @@ -1289,12 +1175,6 @@ namespace NUS_Downloader { WriteStatus("Beginning WAD Pack..."); - // Obtain Current Directory - string currentdir = Directory.GetCurrentDirectory(); - if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) || - !(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString()))) - currentdir += Path.DirectorySeparatorChar.ToString(); - // Create instance of WAD Packing class WADPacker packer = new WADPacker(); packer.StatusChanged += WriteStatus; @@ -1320,8 +1200,8 @@ namespace NUS_Downloader packer.Certs = certsbuf; // Read TMD/TIK into Packer. - packer.Ticket = FileLocationToByteArray(totaldirectory + Path.DirectorySeparatorChar.ToString() + @"cetk"); - packer.TMD = FileLocationToByteArray(totaldirectory + Path.DirectorySeparatorChar.ToString() + tmdfilename); + packer.Ticket = FileLocationToByteArray(Path.Combine(totaldirectory, "cetk")); + packer.TMD = FileLocationToByteArray(Path.Combine(totaldirectory, tmdfilename)); // Get the TMD variables in here instead... int contentcount = ContentCount(packer.TMD); @@ -1340,8 +1220,7 @@ namespace NUS_Downloader } else { - string wad_filename = totaldirectory + Path.DirectorySeparatorChar.ToString() + - RemoveIllegalCharacters(wadnamebox.Text); + string wad_filename = Path.Combine(totaldirectory, RemoveIllegalCharacters(wadnamebox.Text)); packer.Directory = totaldirectory; packer.FileName = System.IO.Path.GetFileName(wad_filename); } @@ -1350,7 +1229,7 @@ namespace NUS_Downloader byte[][] contents_array = new byte[contentcount][]; for (int a = 0; a < contentcount; a++) { - contents_array[a] = FileLocationToByteArray(totaldirectory + contentnames[a]); + contents_array[a] = FileLocationToByteArray(Path.Combine(totaldirectory, contentnames[a])); } packer.Contents = contents_array; @@ -1361,10 +1240,10 @@ namespace NUS_Downloader if (deletecontentsbox.Checked) { WriteStatus("Deleting contents..."); - File.Delete(totaldirectory + Path.DirectorySeparatorChar.ToString() + tmdfilename); - File.Delete(totaldirectory + Path.DirectorySeparatorChar.ToString() + @"cetk"); + File.Delete(Path.Combine(totaldirectory, tmdfilename)); + File.Delete(Path.Combine(totaldirectory, "cetk")); for (int a = 0; a < contentnames.Length; a++) - File.Delete(totaldirectory + Path.DirectorySeparatorChar.ToString() + contentnames[a]); + File.Delete(Path.Combine(totaldirectory, contentnames[a])); WriteStatus(" - Contents have been deleted."); string[] leftovers = Directory.GetFiles(totaldirectory); if (leftovers.Length <= 0) @@ -1376,48 +1255,6 @@ namespace NUS_Downloader } } - /* - /// - /// Returns next 0x40 padded length. - /// - /// The currentlength. - /// - private long ByteBoundary(int currentlength) - { - // Gets the next 0x40 offset. - long thelength = currentlength - 1; - long remainder = 1; - - while (remainder != 0) - { - thelength += 1; - remainder = thelength%0x40; - } - - //WriteStatus("Initial Size: " + currentlength); - //WriteStatus("0x40 Size: " + thelength); - - return (long) thelength; - } - - /// - /// Int -> Byte[] (OLD) - /// - /// The int. - /// The array length. - /// - private byte[] InttoByteArray(int inte, int arraysize) - { - // Take integer and make into byte array - byte[] b = new byte[arraysize]; - b = BitConverter.GetBytes(inte); - - if (BitConverter.IsLittleEndian) - Array.Reverse(b); - - return b; - }*/ - private void consoleCBox_SelectedIndexChanged(object sender, EventArgs e) { if (consoleCBox.SelectedIndex == 0) @@ -1453,25 +1290,23 @@ namespace NUS_Downloader WriteStatus("This application created by WB3000"); WriteStatus("Various sections contributed by lukegb"); WriteStatus(""); - - string currentdir = Directory.GetCurrentDirectory(); - if (File.Exists(Path.Combine(currentdir, "key.bin")) == false) + if (File.Exists(Path.Combine(CURRENT_DIR, "key.bin")) == false) WriteStatus("Wii Decryption: Need (key.bin)"); else WriteStatus("Wii Decryption: OK"); - if (File.Exists(Path.Combine(currentdir, "kkey.bin")) == false) + if (File.Exists(Path.Combine(CURRENT_DIR, "kkey.bin")) == false) WriteStatus("Wii Korea Decryption: Need (kkey.bin)"); else WriteStatus("Wii Korea Decryption: OK"); - if (File.Exists(Path.Combine(currentdir, "dsikey.bin")) == false) + if (File.Exists(Path.Combine(CURRENT_DIR, "dsikey.bin")) == false) WriteStatus("DSi Decryption: Need (dsikey.bin)"); else WriteStatus("DSi Decryption: OK"); - if (File.Exists(Path.Combine(currentdir, "database.xml")) == false) + if (File.Exists(Path.Combine(CURRENT_DIR, "database.xml")) == false) WriteStatus("Database: Need (database.xml)"); else WriteStatus("Database: OK"); @@ -1621,13 +1456,10 @@ namespace NUS_Downloader /// public byte[] LoadCommonKey(string keyfile) { - // Directory stuff - string currentdir = Directory.GetCurrentDirectory(); - - if (File.Exists(Path.Combine(currentdir, keyfile)) == true) + if (File.Exists(Path.Combine(CURRENT_DIR, keyfile)) == true) { // Read common key byte[] - return FileLocationToByteArray(Path.Combine(currentdir, keyfile)); + return FileLocationToByteArray(Path.Combine(CURRENT_DIR, keyfile)); } else return null; @@ -1641,16 +1473,13 @@ namespace NUS_Downloader /// public bool WriteCommonKey(string keyfile, byte[] commonkey) { - // Directory stuff - string currentdir = Directory.GetCurrentDirectory(); - - if (File.Exists(Path.Combine(currentdir, keyfile)) == true) + if (File.Exists(Path.Combine(CURRENT_DIR, keyfile)) == true) { WriteStatus(String.Format("Overwriting old {0}...", keyfile)); } try { - FileStream fs = File.OpenWrite(Path.Combine(currentdir, keyfile)); + FileStream fs = File.OpenWrite(Path.Combine(CURRENT_DIR, keyfile)); fs.Write(commonkey, 0, commonkey.Length); fs.Close(); WriteStatus(String.Format("{0} written - Reloading...", keyfile)); @@ -1698,8 +1527,7 @@ namespace NUS_Downloader private void FillDatabaseStrip(BackgroundWorker worker) { // Load database.xml into memorystream to perhaps reduce disk reads? - string currentdir = Directory.GetCurrentDirectory(); - string databasestr = File.ReadAllText(Path.Combine(currentdir, "database.xml")); + string databasestr = File.ReadAllText(Path.Combine(CURRENT_DIR, "database.xml")); System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); byte[] databasebytes = encoding.GetBytes(databasestr); @@ -2711,7 +2539,7 @@ namespace NUS_Downloader statusbox.Text = ""; WriteStatus("Starting Wii System Update..."); - extrasStrip.Close(); + scriptsStrip.Close(); string deviceID = "4362227770"; string messageID = "13198105123219138"; @@ -2790,17 +2618,14 @@ namespace NUS_Downloader WriteStatus(" - Outputting results to NUS script..."); - // Current directory... - string currentdir = Directory.GetCurrentDirectory(); - - if (!(Directory.Exists(Path.Combine(currentdir, "scripts")))) + if (!(Directory.Exists(Path.Combine(CURRENT_DIR, "scripts")))) { - Directory.CreateDirectory(Path.Combine(currentdir, "scripts")); + Directory.CreateDirectory(Path.Combine(CURRENT_DIR, "scripts")); WriteStatus(" - Created 'scripts\' directory."); } string time = RemoveIllegalCharacters(DateTime.Now.ToShortTimeString()); File.WriteAllText( - String.Format(Path.Combine(currentdir, "scripts\\{0}_Update_{1}_{2}_{3} {4}.nus"), RegionID, + String.Format(Path.Combine(CURRENT_DIR, "scripts\\{0}_Update_{1}_{2}_{3} {4}.nus"), RegionID, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, time), script_text); WriteStatus(" - Script written!"); WriteStatus(" - Run this script if you feel like downloading the update!"); @@ -2974,13 +2799,10 @@ namespace NUS_Downloader private void SaveProxyBtn_Click(object sender, EventArgs e) { - // Current directory... - string currentdir = Directory.GetCurrentDirectory(); - if ((String.IsNullOrEmpty(ProxyURL.Text)) && (String.IsNullOrEmpty(ProxyUser.Text)) && - ((File.Exists(Path.Combine(currentdir, "proxy.txt"))))) + ((File.Exists(Path.Combine(CURRENT_DIR, "proxy.txt"))))) { - File.Delete(Path.Combine(currentdir, "proxy.txt")); + File.Delete(Path.Combine(CURRENT_DIR, "proxy.txt")); proxyBox.Visible = false; proxy_usr = ""; proxy_url = ""; @@ -2989,7 +2811,7 @@ namespace NUS_Downloader return; } else if ((String.IsNullOrEmpty(ProxyURL.Text)) && (String.IsNullOrEmpty(ProxyUser.Text)) && - ((!(File.Exists(Path.Combine(currentdir, "proxy.txt")))))) + ((!(File.Exists(Path.Combine(CURRENT_DIR, "proxy.txt")))))) { proxyBox.Visible = false; WriteStatus("No proxy settings saved!"); @@ -3012,7 +2834,7 @@ namespace NUS_Downloader if (!(String.IsNullOrEmpty(proxy_file))) { - File.WriteAllText(Path.Combine(currentdir, "proxy.txt"), proxy_file); + File.WriteAllText(Path.Combine(CURRENT_DIR, "proxy.txt"), proxy_file); WriteStatus("Proxy settings saved!"); } @@ -3028,13 +2850,10 @@ namespace NUS_Downloader private void proxySettingsToolStripMenuItem_Click(object sender, EventArgs e) { - // Current directory... - string currentdir = Directory.GetCurrentDirectory(); - // Check for Proxy Settings file... - if (File.Exists(Path.Combine(currentdir, "proxy.txt")) == true) + if (File.Exists(Path.Combine(CURRENT_DIR, "proxy.txt")) == true) { - string[] proxy_file = File.ReadAllLines(Path.Combine(currentdir, "proxy.txt")); + string[] proxy_file = File.ReadAllLines(Path.Combine(CURRENT_DIR, "proxy.txt")); ProxyURL.Text = proxy_file[0]; if (proxy_file.Length > 1) @@ -3068,15 +2887,12 @@ namespace NUS_Downloader private void loadNUSScriptToolStripMenuItem_Click(object sender, EventArgs e) { - // Current directory... - string currentdir = Directory.GetCurrentDirectory(); - // Open a NUS script. OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = false; ofd.Filter = "NUS Scripts|*.nus|All Files|*.*"; - if (Directory.Exists(Path.Combine(currentdir, "scripts"))) - ofd.InitialDirectory = Path.Combine(currentdir, "scripts"); + if (Directory.Exists(Path.Combine(CURRENT_DIR, "scripts"))) + ofd.InitialDirectory = Path.Combine(CURRENT_DIR, "scripts"); ofd.Title = "Load a NUS/Wiimpersonator script."; if (ofd.ShowDialog() != DialogResult.Cancel) @@ -3235,6 +3051,17 @@ namespace NUS_Downloader } } + string CombinePaths(params string[] parts) + { + string result = String.Empty; + foreach (string s in parts) + { + result = Path.Combine(result, s); + } + return result; + } + + private void scriptsbutton_Click(object sender, EventArgs e) { // Show scripts menu diff --git a/NUS Downloader/Properties/Resources.Designer.cs b/NUS Downloader/Properties/Resources.Designer.cs index 20372dd..1be059c 100644 --- a/NUS Downloader/Properties/Resources.Designer.cs +++ b/NUS Downloader/Properties/Resources.Designer.cs @@ -144,13 +144,6 @@ namespace NUS_Downloader.Properties { } } - internal static System.Drawing.Bitmap dsi { - get { - object obj = ResourceManager.GetObject("dsi", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - internal static System.Drawing.Bitmap help { get { object obj = ResourceManager.GetObject("help", resourceCulture); @@ -213,12 +206,5 @@ namespace NUS_Downloader.Properties { return ((System.Drawing.Bitmap)(obj)); } } - - internal static System.Drawing.Bitmap wilolgoi { - get { - object obj = ResourceManager.GetObject("wilolgoi", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } } } diff --git a/NUS Downloader/Properties/Resources.resx b/NUS Downloader/Properties/Resources.resx index 067d754..164ba79 100644 --- a/NUS Downloader/Properties/Resources.resx +++ b/NUS Downloader/Properties/Resources.resx @@ -117,7 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + ..\direction_down.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -130,18 +130,12 @@ ..\Resources\arrow_up.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\wilolgoi.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\bullet_redgreen.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\arrow_down.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\dsi.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\server_connect.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/NUS Downloader/WADPacker.cs b/NUS Downloader/WADPacker.cs index 889d3c1..ada7cf4 100644 --- a/NUS Downloader/WADPacker.cs +++ b/NUS Downloader/WADPacker.cs @@ -129,7 +129,7 @@ namespace NUS_Downloader return; } - FileStream wadfs = new FileStream((Directory + FileName), FileMode.Create); + FileStream wadfs = new FileStream(Path.Combine(Directory, FileName), FileMode.Create); // Seek the beginning of the WAD... wadfs.Seek(0, SeekOrigin.Begin);