예제 #1
0
        void DoSave()
        {
            FileChanged = false;
            CountedStreamWriter pf = new CountedStreamWriter(FileName);

            LootRules.Write(pf);
            pf.Close();
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }