예제 #1
0
        public static void CharakterSave(out DSAError error)
        {
            error = null;
            try
            {
                var saveFile = Charakter.CreateSave();
                var filePath = Path.Combine(CharakterSaveFolder, Charakter.ID.ToString() + ".save");
                FileManagment.WriteToFile(saveFile.JSONContent, filePath, Windows.Storage.CreationCollisionOption.ReplaceExisting, out error);

                #region Sicherungskopie
                var task = new Task(async() =>
                {
                    try
                    {
                        var folder = await StorageFolder.GetFolderFromPathAsync("D:\\Dropbox\\07_DSA_PNP_D&D\\DSA_Save");
                        var sfile  = await folder.CreateFileAsync(Charakter.ID.ToString() + ".save", CreationCollisionOption.ReplaceExisting);
                        await FileIO.AppendTextAsync(sfile, saveFile.JSONContent);
                    }
                    catch (Exception)
                    {
                        Logger.Log(LogLevel.ErrorLog, "Sicherung konnte nicht erstellt werden");
                        //"https://support.microsoft.com/de-de/help/4468237/windows-10-file-system-access-and-privacy-microsoft-privacy"
                    }
                });
                task.Start();
                #endregion
            }
            catch (Exception ex)
            {
                error = new DSAError
                {
                    ErrorCode = ErrorCode.Error,
                    Message   = ex.Message
                };
            }
        }