private void AddFileToFolder(PackageFolder folder, string file) { if (folder == null) { string guessFolderName = FileHelper.GuessFolderNameFromFile(file); bool confirmed = UIServices.Confirm( String.Format(CultureInfo.CurrentCulture, Resources.ConfirmToMoveFileIntoFolder, file, guessFolderName)); if (confirmed) { if (RootFolder.ContainsFolder(guessFolderName)) { folder = (PackageFolder)RootFolder[guessFolderName]; } else { folder = RootFolder.AddFolder(guessFolderName); } } else { folder = RootFolder; } } folder.AddFile(file); }
internal void ExportManifest(string fullpath, bool askForConfirmation = true, bool includeFilesSection = true) { if (File.Exists(fullpath) && askForConfirmation) { var confirmed = UIServices.Confirm( Resources.ConfirmToReplaceFile_Title, string.Format(CultureInfo.CurrentCulture, Resources.ConfirmToReplaceFile, fullpath)); if (!confirmed) { return; } } var rootPath = Path.GetDirectoryName(fullpath); using (Stream fileStream = File.Create(fullpath)) { var manifest = Manifest.Create(PackageMetadata); if (includeFilesSection) { var tempPath = Path.GetTempPath(); manifest.Files.AddRange(RootFolder.GetFiles().Select( f => new ManifestFile { Source = string.IsNullOrEmpty(f.OriginalPath()) || f?.OriginalPath()?.StartsWith(tempPath, StringComparison.OrdinalIgnoreCase) == true ? f.Path : PathUtility.RelativePathTo(rootPath, f.OriginalPath() !), Target = f.Path })
internal void ExportManifest(string fullpath, bool askForConfirmation = true, bool includeFilesSection = true) { if (File.Exists(fullpath) && askForConfirmation) { var confirmed = UIServices.Confirm( Resources.ConfirmToReplaceFile_Title, string.Format(CultureInfo.CurrentCulture, Resources.ConfirmToReplaceFile, fullpath)); if (!confirmed) { return; } } var rootPath = Path.GetDirectoryName(fullpath); using (Stream fileStream = File.Create(fullpath)) { var manifest = Manifest.Create(PackageMetadata); if (includeFilesSection) { var tempPath = Path.GetTempPath(); manifest.Files.AddRange(RootFolder.GetFiles().Select( f => new ManifestFile { Source = string.IsNullOrEmpty(f.OriginalPath()) || f.OriginalPath().StartsWith(tempPath, StringComparison.OrdinalIgnoreCase) ? f.Path : PathUtility.RelativePathTo(rootPath, f.OriginalPath()), Target = f.Path }) ); } using (var ms = new MemoryStream()) { try { manifest.Save(ms); ms.Position = 0; ManifestUtility.SaveToStream(ms, fileStream); } catch (Exception e) { UIServices.Show(e.Message, MessageLevel.Error); } } } }
internal void ExportManifest(string fullpath) { if (File.Exists(fullpath)) { bool confirmed = UIServices.Confirm( String.Format(CultureInfo.CurrentCulture, Resources.ConfirmToReplaceFile, fullpath) ); if (!confirmed) { return; } } using (Stream fileStream = File.Create(fullpath)) { Manifest manifest = Manifest.Create(PackageMetadata); manifest.Save(fileStream); } }