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, 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 })