Ejemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         handleTable?.Dispose();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 压缩多个文件
        /// </summary>
        /// <param name="streams">多个文件流</param>
        /// <param name="zipFile">压缩到...</param>
        /// <param name="archiveType"></param>
        /// <param name="disposeAllStreams">是否需要释放所有流</param>
        public void Zip(DisposableDictionary <string, Stream> streams, string zipFile, ArchiveType archiveType = ArchiveType.Zip, bool disposeAllStreams = false)
        {
            using var archive = ArchiveFactory.Create(archiveType);
            foreach (var pair in streams)
            {
                archive.AddEntry(pair.Key, pair.Value, true);
            }

            archive.SaveTo(zipFile, new WriterOptions(CompressionType.LZMA)
            {
                LeaveStreamOpen = true,
                ArchiveEncoding = new ArchiveEncoding()
                {
                    Default = Encoding.UTF8
                }
            });
            if (disposeAllStreams)
            {
                streams.Dispose();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 将多个文件压缩到一个文件流中,可保存为zip文件,方便于web方式下载
        /// </summary>
        /// <param name="streams">多个文件流</param>
        /// <param name="archiveType"></param>
        /// <param name="disposeAllStreams">是否需要释放所有流</param>
        /// <returns>文件流</returns>
        public static MemoryStream ZipStream(DisposableDictionary <string, Stream> streams, ArchiveType archiveType = ArchiveType.Zip, bool disposeAllStreams = false)
        {
            using var archive = ArchiveFactory.Create(archiveType);
            foreach (var pair in streams)
            {
                archive.AddEntry(pair.Key, pair.Value, true);
            }

            var ms = new MemoryStream();

            archive.SaveTo(ms, new WriterOptions(CompressionType.LZMA)
            {
                LeaveStreamOpen = true,
                ArchiveEncoding = new ArchiveEncoding()
                {
                    Default = Encoding.UTF8
                }
            });
            if (disposeAllStreams)
            {
                streams.Dispose();
            }
            return(ms);
        }
Ejemplo n.º 4
0
 public void Dispose()
 {
     handleTable?.Dispose();
 }
Ejemplo n.º 5
0
 public void Dispose()
 {
     m_createdMaterials.Dispose();
 }
Ejemplo n.º 6
0
 public void Dispose()
 {
     m_textureCache.Dispose();
     m_defaultTextures.Dispose();
     m_detector.Dispose();
 }