I wrote a sample follow the documentation.
public static void Compress(string[] filesList, string descZipFolder,bool IsDelOrginalFile)
what shall I do? Is is the reason that I didn't close the stream?
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?