Example #1
0
        private void MenuItem_SaveClick(object sender, RoutedEventArgs e)
        {
            string valheimSaveFolder = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @"Appdata\LocalLow\IronGate\Valheim\characters");

            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog
            {
                Filter           = "FCH Files (*.fch)|*.fch",
                InitialDirectory = valheimSaveFolder,
                FileName         = character.Name,
                DefaultExt       = ".fch"
            };
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                if (File.Exists(dlg.FileName))
                {
                    string backupFileName = character.Name + "_" + DateTime.Now.ToString("yyyyMMddHHmm") + ".fch.backup";
                    File.Move(dlg.FileName, System.IO.Path.Combine(valheimSaveFolder, backupFileName));
                }
                string fileName         = dlg.FileName;
                byte[] characterAsBytes = FchParser.CharacterToArray(character);
                File.WriteAllBytes(fileName, characterAsBytes);
            }
        }
Example #2
0
        private void MenuItem_OpenClick(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog
            {
                Filter           = "FCH Files (*.fch)|*.fch",
                InitialDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @"Appdata\LocalLow\IronGate\Valheim\characters")
            };
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                string filename = dlg.FileName;
                character         = FchParser.ReadCharacterData(filename);
                isCharacterLoaded = true;
                PopulateForm();
            }
        }