SavePackage() private méthode

private SavePackage ( IPackageMetadata packageMetadata, IEnumerable files, string targetFilePath, bool useTempFile ) : void
packageMetadata IPackageMetadata
files IEnumerable
targetFilePath string
useTempFile bool
Résultat void
Exemple #1
0
        public string GetCurrentPackageTempFile()
        {
            var tempFile = Path.GetTempFileName();

            try
            {
                // handle signed packages since they cannot be resaved without losing the signature
                if (IsSigned && _package is ISignaturePackage zip)
                {
                    File.Copy(zip.Source, tempFile, overwrite: true);
                }
                else
                {
                    PackageHelper.SavePackage(PackageMetadata, GetFiles(), tempFile, useTempFile: false);
                }
            }
            catch (Exception e)
            {
                UIServices.Show(e.Message, MessageLevel.Error);
            }

            if (File.Exists(tempFile))
            {
                return(tempFile);
            }

            return(null);
        }
Exemple #2
0
        public string?GetCurrentPackageTempFile()
        {
            var tempFile = Path.GetTempFileName();

            try
            {
                // handle signed packages since they cannot be resaved without losing the signature
                if (IsSigned)
                {
                    File.Copy(PackagePath, tempFile, overwrite: true);
                }
                else
                {
                    PackageHelper.SavePackage(PackageMetadata, GetFiles(), tempFile, useTempFile: false);
                }
            }
            catch (Exception e)
            {
                if (!(e is ArgumentException))
                {
                    DiagnosticsClient.Notify(e);
                }
                UIServices.Show(e.Message, MessageLevel.Error);
            }

            if (File.Exists(tempFile))
            {
                return(tempFile);
            }

            return(null);
        }
 private void SavePackage(string fileName)
 {
     try {
         PackageHelper.SavePackage(ViewModel.PackageMetadata, ViewModel.GetFiles(), fileName, true);
         ViewModel.OnSaved(fileName);
     }
     catch (Exception ex) {
         ViewModel.UIServices.Show(ex.Message, MessageLevel.Error);
     }
 }
        public string GetCurrentPackageTempFile()
        {
            string tempFile = Path.GetTempFileName();

            PackageHelper.SavePackage(PackageMetadata, GetFiles(), tempFile, useTempFile: false);
            if (File.Exists(tempFile))
            {
                return(tempFile);
            }

            return(null);
        }
Exemple #5
0
        public Stream GetCurrentPackageStream()
        {
            string tempFile = Path.GetTempFileName();

            PackageHelper.SavePackage(PackageMetadata, GetFiles(), tempFile, false);
            if (File.Exists(tempFile))
            {
                return(File.OpenRead(tempFile));
            }
            else
            {
                return(null);
            }
        }
        public string GetCurrentPackageTempFile()
        {
            // handle signed packages since they cannot be resaved without losing the signature
            if (IsSigned && _package is ZipPackage zip)
            {
                return(zip.Source);
            }

            string tempFile = Path.GetTempFileName();

            PackageHelper.SavePackage(PackageMetadata, GetFiles(), tempFile, useTempFile: false);
            if (File.Exists(tempFile))
            {
                return(tempFile);
            }

            return(null);
        }