ICSharpCode.SharpZipLib.Zip.ZipFile.Close C# (CSharp) Method

Close() public method

Closes the ZipFile. If the stream is owned then this also closes the underlying input stream. Once closed, no further instance methods should be called.
/// An i/o error occurs. ///
public Close ( ) : void
return void
        public void Close() {
            DisposeInternal(true);
            GC.SuppressFinalize(this);
        }

Usage Example

Ejemplo n.º 1
1
        /// <summary>
        /// Add files to an existing Zip archive, 
        /// </summary>
        /// <param name="filename">Array of path / filenames to add to the archive</param>
        /// <param name="archive">Zip archive that we want to add the file to</param>
        public void AddToZip(string[] filename, string archive)
        {
            if (!File.Exists(archive))
            {
                return;
            }

            try
            {
                ZipFile zf = new ZipFile(archive);
                zf.BeginUpdate();
                // path relative to the archive
                zf.NameTransform = new ZipNameTransform(Path.GetDirectoryName(archive));
                foreach (var file in filename)
                {
                    // skip if this isn't a real file
                    if (!File.Exists(file))
                    {
                        continue;
                    }
                    zf.Add(file, CompressionMethod.Deflated);
                }
                zf.CommitUpdate();
                zf.Close();
            }
            catch (Exception e)
            {
                if (e.Message != null)
                {
                    var msg = new[] { e.Message };
                    LocDB.Message("defErrMsg", e.Message, msg, LocDB.MessageTypes.Error, LocDB.MessageDefault.First);
                }
            }
        }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.ZipFile::Close