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

New Post: File not disposed after use

$
0
0

this could be a very useful library, but i'm sorry to report some errors that i can't understand:

ERROR 1: files not disposed after use: both zip file and archiving files

ERROR 2: file zip created not a valid archive

I created this simple winform to try to understand where i make mistakes:

privatevoid btnRun_Click(object sender, EventArgs e)
        {
            comprexFile(@"d:\backup\emanuele.zip", @"D:\toZipping\10122014\2012-06-01-08-18-04-6567-007.batchstate");
        }

        privatevoid comprexFile(string zipFile, string fileToArchive)
        {
            checkZipFile(zipFile);
            using (var zipArchive = ZipArchive.Open(zipFile, null))
            {
                FileInfo fInfo = new FileInfo(fileToArchive);
                zipArchive.AddEntry(fileToArchive, fInfo);

                using (Stream zipStream = File.OpenWrite(zipFile))
                {
                    CompressionInfo cInfo = new CompressionInfo();
                    cInfo.Type = CompressionType.None;
                    zipArchive.SaveTo(zipStream, cInfo);
                }
            }
        }

        privatevoid checkZipFile(string zipFile)
        {
            if (!File.Exists(zipFile))
            {
                using (var myArchive = ZipArchive.Create())
                {
                    using (Stream zipStream = File.Create(zipFile))
                    {
                        CompressionInfo cInfo = new CompressionInfo();
                        cInfo.Type = CompressionType.None;
                        myArchive.SaveTo(zipStream, cInfo);
                    }

                }
            }
        }

but i can't solve it

Thanks for your reply

Emanuele


Viewing all articles
Browse latest Browse all 239

Trending Articles



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