コード例 #1
0
        private async Task <string> GetBuildsSavePathAsync()
        {
            if (AppData.IsPortable)
            {
                return(AppData.ToRelativePath(AppData.GetFolder("Builds")));
            }

            // Ask user for path. Default: AppData.GetFolder("Builds")
            var dialogSettings = new FileSelectorDialogSettings
            {
                DefaultPath       = AppData.GetFolder("Builds"),
                IsFolderPicker    = true,
                ValidationSubPath = GetLongestRequiredSubpath(),
                IsCancelable      = false
            };

            if (!DeserializesBuildsSavePath)
            {
                dialogSettings.AdditionalValidationFunc =
                    path => Directory.Exists(path) && Directory.EnumerateFileSystemEntries(path).Any()
                        ? L10n.Message("Directory must be empty.")
                        : null;
            }
            return((await DialogCoordinator.ShowFileSelectorAsync(PersistentData,
                                                                  L10n.Message("Select build directory"),
                                                                  L10n.Message("Select the directory where builds will be stored.\n" +
                                                                               "It will be created if it does not yet exist. You can change it in the settings later."),
                                                                  dialogSettings)) !);
        }