コード例 #1
0
        /// <summary>
        /// Extract a package in one step, treating the manifest like any other file.
        /// </summary>
        /// <param name="packagePath">The full file path of the package.</param>
        /// <param name="rsaParamsXml">RSA key serialized to XML. If null, extract an unencrypted package.</param>
        /// <param name="targetFolderPath">The folder where the file should be extracted to. This folder will be created if needed. Any existing file will be overwritten.</param>
        public static void ExtractAllFiles(string packagePath, string rsaParamsXml, string targetFolderPath)
        {
            TemplatePackage package = new TemplatePackage();

            package.Open(packagePath, rsaParamsXml);
            foreach (var s in package.GetFiles(true))
            {
                package.ExtractFile(s, targetFolderPath);
            }
        }
コード例 #2
0
 /// <summary>
 /// Extract the create the package content folder and extract the package content to it.
 /// </summary>
 /// <param name="force">If true, the directory is overwritten. Otherwise, the directory
 /// is created and files extracted only if the directory does not exist. If force is true
 /// all previously existing directory content is destroyed.</param>
 public virtual void ExtractPackageFiles(bool force = false)
 {
     if (force)
     {
         CleanPackageFiles();
     }
     if (!Directory.Exists(_templateDir))
     {
         Directory.CreateDirectory(_templateDir);
         TemplatePackage.ExtractAllFiles(PackagePath, "", _templateDir);
     }
 }
コード例 #3
0
        /// <summary>
        /// Create a package in one step.
        /// </summary>
        /// <param name="packagePath">The full file path were the package should be written to. Any existing file will be overwritten.</param>
        /// <param name="manifest">The manifest of the package. Passing null creates a package without a manifest.</param>
        /// <param name="filePaths">A complete list of all file paths to be added to the package.</param>
        /// <param name="rsaParamsXml">RSA key serialized to XML. It can be a public/private key pair or only a public key. If null, save an unencrypted package.</param>
        /// <param name="compression">The compression level.</param>
        public static void Create(string packagePath, TemplatePackageManifest manifest, IEnumerable <string> filePaths, string rsaParamsXml, CompressionOption compression)
        {
            TemplatePackage package = new TemplatePackage();

            //
            package.CurrentCompression = compression;
            foreach (var s in filePaths)
            {
                package.AddFile(s);
            }
            package.Manifest = manifest;
            package.SaveAs(packagePath, rsaParamsXml);
        }
コード例 #4
0
        /// <summary>
        /// Extract a package in one step.
        /// </summary>
        /// <param name="packagePath">The full file path of the package.</param>
        /// <param name="rsaParamsXml">RSA key serialized to XML. If null, extract an unencrypted package.</param>
        /// <param name="targetFolderPath">The folder where the file should be extracted to. This folder will be created if needed. Any existing file will be overwritten.</param>
        /// <param name="manifest">The manifest of the package. If null, the package had no manifest.</param>
        /// <param name="filePaths">A list containing the full file paths of all extracted files.</param>
        public static void Extract(string packagePath, string rsaParamsXml, string targetFolderPath,
                                   out TemplatePackageManifest manifest, out IEnumerable <string> filePaths)
        {
            TemplatePackage package  = new TemplatePackage();
            List <string>   fileList = new List <string>();
            string          path;

            //
            package.Open(packagePath, rsaParamsXml);
            foreach (var s in package.GetFiles())
            {
                path = package.ExtractFile(s, targetFolderPath);
                fileList.Add(path);
            }
            manifest  = package.Manifest;
            filePaths = fileList;
        }
コード例 #5
0
 /// <summary>
 /// Extract a package in one step, treating the manifest like any other file.
 /// </summary>
 /// <param name="packagePath">The full file path of the package.</param>
 /// <param name="rsaParamsXml">RSA key serialized to XML. If null, extract an unencrypted package.</param>
 /// <param name="targetFolderPath">The folder where the file should be extracted to. This folder will be created if needed. Any existing file will be overwritten.</param>
 public static void ExtractAllFiles(string packagePath, string rsaParamsXml, string targetFolderPath)
 {
     TemplatePackage package = new TemplatePackage();
     package.Open(packagePath, rsaParamsXml);
     foreach (var s in package.GetFiles(true))
     {
         package.ExtractFile(s, targetFolderPath);
     }
 }
コード例 #6
0
        /// <summary>
        /// Extract a package in one step.
        /// </summary>
        /// <param name="packagePath">The full file path of the package.</param>
        /// <param name="rsaParamsXml">RSA key serialized to XML. If null, extract an unencrypted package.</param>
        /// <param name="targetFolderPath">The folder where the file should be extracted to. This folder will be created if needed. Any existing file will be overwritten.</param>
        /// <param name="manifest">The manifest of the package. If null, the package had no manifest.</param>
        /// <param name="filePaths">A list containing the full file paths of all extracted files.</param>
        public static void Extract(string packagePath, string rsaParamsXml, string targetFolderPath,
								   out TemplatePackageManifest manifest, out IEnumerable<string> filePaths)
        {
            TemplatePackage package = new TemplatePackage();
            List<string> fileList = new List<string>();
            string path;
            //
            package.Open(packagePath, rsaParamsXml);
            foreach (var s in package.GetFiles())
            {
                path = package.ExtractFile(s, targetFolderPath);
                fileList.Add(path);
            }
            manifest = package.Manifest;
            filePaths = fileList;
        }
コード例 #7
0
 /// <summary>
 /// Create a package in one step.
 /// </summary>
 /// <param name="packagePath">The full file path were the package should be written to. Any existing file will be overwritten.</param>
 /// <param name="manifest">The manifest of the package. Passing null creates a package without a manifest.</param>
 /// <param name="filePaths">A complete list of all file paths to be added to the package.</param>
 /// <param name="rsaParamsXml">RSA key serialized to XML. It can be a public/private key pair or only a public key. If null, save an unencrypted package.</param>
 /// <param name="compression">The compression level.</param>
 public static void Create(string packagePath, TemplatePackageManifest manifest, IEnumerable<string> filePaths, string rsaParamsXml, CompressionOption compression, bool checkForGeneratedFiles)
 {
     TemplatePackage package = new TemplatePackage();
     package.CheckForGeneratedFiles = checkForGeneratedFiles;
     //
     package.CurrentCompression = compression;
     foreach (var s in filePaths)
     {
         package.AddFile(s);
     }
     package.Manifest = manifest;
     package.SaveAs(packagePath, rsaParamsXml);
 }