public override void LoadProfile(string filename, bool newprofile) { try { #if DEBUGMSG neededid = 0; noid = 0; #endif if (newprofile) { LootRules = new cLootRules(); using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) { using (CountedStreamWriter sr = new CountedStreamWriter(fs)) { LootRules.Write(sr); } } WriteToChat("Created blank profile " + filename + "."); } else { if (!System.IO.File.Exists(filename)) { return; } LootRules = new cLootRules(); using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)) { using (System.IO.StreamReader sr = new System.IO.StreamReader(fs)) { if (LootRules.Read(sr, -1)) { WriteToChat("Load profile " + filename + " successful (file version " + LootRules.UTLFileVersion.ToString() + ")."); } else { WriteToChat("Load profile " + filename + " returned an error. Your entire profile may not have loaded properly."); } } } } } catch (Exception ex) { ExceptionHandler(ex); } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (!CheckSave()) { return; } FileChanged = false; FileName = ""; this.Text = AppName + " - New File"; LootRules = new cLootRules(); lstRules.Items.Clear(); SetCurrentReq(null, 0); SetCurrentRule(null, 0); RefreshTabData(); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (!CheckSave()) return; FileChanged = false; FileName = ""; this.Text = AppName + " - New File"; LootRules = new cLootRules(); lstRules.Items.Clear(); SetCurrentReq(null, 0); SetCurrentRule(null, 0); RefreshTabData(); }
public override void LoadProfile(string filename, bool newprofile) { try { #if DEBUGMSG neededid = 0; noid = 0; #endif if (newprofile) { LootRules = new cLootRules(); using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) { using (CountedStreamWriter sr = new CountedStreamWriter(fs)) { LootRules.Write(sr); } } WriteToChat("Created blank profile " + filename + "."); } else { if (!System.IO.File.Exists(filename)) return; LootRules = new cLootRules(); using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)) { using (System.IO.StreamReader sr = new System.IO.StreamReader(fs)) { if (LootRules.Read(sr, -1)) WriteToChat("Load profile " + filename + " successful (file version " + LootRules.UTLFileVersion.ToString() + ")."); else WriteToChat("Load profile " + filename + " returned an error. Your entire profile may not have loaded properly."); } } } } catch (Exception ex) { ExceptionHandler(ex); } }