private void LoadFile(string fileName) { if (string.IsNullOrEmpty(fileName)) { return; } FileName = fileName; FileChanged = false; this.Text = AppName + " - " + FileName; LastBackup = DateTimeOffset.MinValue; System.IO.StreamReader pf = new System.IO.StreamReader(FileName); LootRules.Read(pf, 0); pf.Close(); Working = true; lstRules.Items.Clear(); foreach (cLootItemRule ir in LootRules.Rules) { lstRules.Items.Add(ir.name); } Working = false; 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); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (!CheckSave()) { return; } System.Windows.Forms.OpenFileDialog od = new OpenFileDialog(); od.DefaultExt = ".utl"; od.Filter = "uTank settings files|*.utl"; od.InitialDirectory = GetVTankProfileDirectory(); od.ShowDialog(); if (od.FileName != "") { FileName = od.FileName; FileChanged = false; this.Text = AppName + " - " + FileName; System.IO.StreamReader pf = new System.IO.StreamReader(FileName); LootRules.Read(pf, 0); pf.Close(); Working = true; lstRules.Items.Clear(); foreach (cLootItemRule ir in LootRules.Rules) { lstRules.Items.Add(ir.name); } Working = false; 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); } }