Example #1
0
            /// Returns a writable stream to an empty subfile.
            public Stream GetWriteStream(string subfileName)
            {
                Debug.Assert(!m_finished);
                if (m_zipstream != null)
                {
#if USE_DOTNETZIP
                    var entry = m_zipstream.PutNextEntry(subfileName);
                    entry.LastModified = System.DateTime.Now;
                    // entry.CompressionMethod = DotNetZip.CompressionMethod.None; no need; use the default
                    return(new ZipOutputStreamWrapper_DotNetZip(m_zipstream));
#else
                    var entry = new ZipLibrary.ZipEntry(subfileName);
                    entry.DateTime = System.DateTime.Now;
                    // There is such a thing as "Deflated, compression level 0".
                    // Explicitly use "Stored".
                    entry.CompressionMethod = (m_zipstream.GetLevel() == 0)
          ? ZipLibrary.CompressionMethod.Stored
          : ZipLibrary.CompressionMethod.Deflated;
                    return(new ZipOutputStreamWrapper_SharpZipLib(m_zipstream, entry));
#endif
                }
                else
                {
                    Directory.CreateDirectory(m_temporaryPath);
                    string fullPath = Path.Combine(m_temporaryPath, subfileName);
                    return(new FileStream(fullPath, FileMode.Create, FileAccess.Write));
                }
            }