コード例 #1
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string         FilePath;
            SaveFileDialog Dialog = new SaveFileDialog();

            Dialog.InitialDirectory = m_SaveFolderPath;
            Dialog.Filter           = "ZT Config File (*.z)|*.z";

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                m_SaveFolderPath = Path.GetDirectoryName(Dialog.FileName);
                Properties.Settings.Default.SaveFolder = m_SaveFolderPath;
                FilePath = Dialog.FileName;
            }
            else
            {
                return;
            }

            saveBody();

            FileStream Stream      = new FileStream(FilePath, FileMode.Create, FileAccess.Write);
            int        ElementSize = Marshal.SizeOf(typeof(MuDef.MUFile_ClientCommon));

            byte[] Temp = BmdFile.StructureToByteArray(m_Body);
            BmdFile.XorFilter(ref Temp, Marshal.SizeOf(typeof(MuDef.MUFile_ClientCommon)));
            Stream.Write(Temp, 0, ElementSize);
            Stream.Close();

            MessageBox.Show(FilePath + " has been saved", "zFileManager");
            Properties.Settings.Default.SaveFolder = Path.GetDirectoryName(FilePath);
            Properties.Settings.Default.Save();
        }
コード例 #2
0
        object readInfo(string File)
        {
            FileStream Stream      = new FileStream(File, FileMode.Open, FileAccess.Read);
            int        ElementSize = Marshal.SizeOf(typeof(MuDef.MUFile_ClientCommon));

            byte[] m_File = new byte[ElementSize + 1];
            m_FileSize = Stream.Read(m_File, 0, ElementSize);
            object DecryptedInfo = Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(m_File, 0), typeof(MuDef.MUFile_ClientCommon));

            BmdFile.XorFilter(ref DecryptedInfo);
            Stream.Close();
            return(DecryptedInfo);
        }