Quantcast
Channel: sharpcompress Discussions Rss Feed
Viewing all articles
Browse latest Browse all 239

New Post: Issue

$
0
0
I wrote a sample follow the documentation.

public static void Compress(string[] filesList, string descZipFolder,bool IsDelOrginalFile)
    {
        CompressionInfo info = new CompressionInfo();
        info.Type = CompressionType.Deflate;
        info.DeflateCompressionLevel = global::SharpCompress.Compressor.Deflate.CompressionLevel.Level6;
        using (var zip = File.OpenWrite(Path.Combine(descZipFolder, GenerateZipFileName())))
        {
            using (var zipWriter = WriterFactory.Open(zip, ArchiveType.Zip, info))
            {
                foreach (var filePath in filesList)
                {
                    zipWriter.Write(Path.GetFileName(filePath), filePath);
                }

            }
        }
        if (IsDelOrginalFile)
        {
            filesList.ToList().ForEach(item => File.Delete(item));
        }
    }
but i didn't delete the orginal file, it shown me the message "It is used by another process, you can't access it."

what shall I do? Is is the reason that I didn't close the stream?

Viewing all articles
Browse latest Browse all 239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>