Beispiel #1
0
        /// <summary>
        /// Extracts the resource to a directory.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <exception cref="ArgumentNullException">
        /// path
        /// or
        /// DBLEntryUid
        /// or
        /// Name
        /// </exception>
        /// <remarks>
        /// After the resource is extracted, it can be a source or target.
        /// </remarks>
        public void ExtractToDirectory(string path)
        {
            // Check parameters
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            else if (string.IsNullOrWhiteSpace(this.DBLEntryUid))
            {
                throw new ArgumentNullException(nameof(this.DBLEntryUid));
            }
            else if (string.IsNullOrWhiteSpace(this.Name))
            {
                throw new ArgumentNullException(nameof(this.Name));
            }

            string resourceFile = ScrTextCollection.GetResourcePath(this.ExistingScrText, this.Name, this.DBLEntryUid);

            if (RobustFile.Exists(resourceFile))
            {
                using var zipFile = ZipFile.Read(resourceFile);
                zipFile.Password  = this._passwordProvider?.GetPassword();
                zipFile.ExtractAll(path, ExtractExistingFileAction.DoNotOverwrite);
            }
        }