Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

StreamUtils not part of ICSharpCode.SharpZipLib.Core namespace

$
0
0

I'm writing a C# application, which needs to decompress a zipfile and copy the files to a particular directory.

I'm using the ICSharpCode.SharpZipLib library, which lists the Runtime Version as v1.1.4322.

I'm using it in conjunction with PDFBox 1.7.0 and IKVM.

I've referenced the namespaces ICSharpCode.SharpZipLib.Core and ICSharpCode.SharpZipLib.Zip in my using statements.

Using an example I found online for extracting the zip file and copying it to a destination folder. (The example is shown below. )

The problem I've run into is that when I type "StreamUtils", the code doesn't recognize this as being part of the ICSharpCode.SharpZipLib.Core namespace. What am I missing in order to make use of "StreamUtils" and "zf.IsStreamOwner"?

I'm receiving the error 'The type or namespace name 'StreamUtils' does not exist in the namespace 'ICSharpCode.SharpZipLib.Core' (are you missing an assembly reference?) and for the zf.IsStreamOwner 'ICSharpCode.SharpZipLib.Zip.ZipFile' does not contain a definition for 'IsStreamOwner' and no extension method 'IsStreamOwner' accepting a first argument of type 'ICSharpCode.SharpZipLib.Zip.ZipFile' could be found (are you missing a using directive or an assembly reference?)

Do I need to use a newer version of the ICSharpCode.SharpZipLib? 

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;


namespace myNamespace
{
    /// <summary>
    /// This class performs file decompression using the ICSharpCode.SharpZipLib library.
    /// </summary>
   public class Deflate
    {
       // Read and unzip data in appropriate directory
       public void ExtractZipFile(string archiveFileNameIn, string outFolder)
       {
           ZipFile zf = null;
           try
           {
               FileStream fs = File.OpenRead(archiveFileNameIn); //read in the zipped file name
               zf = new ZipFile(fs);

               foreach (ZipEntry zipEntry in zf)//loop thru each file within the zipped archive. Extract each in turn.
               {
                   if (!zipEntry.IsFile)//ignore directory structures
                   {
                       continue;
                   }
                   String entryFileName = zipEntry.Name;

                   byte[ buffer = new byte[4096];
                   Stream zipStream = zf.GetInputStream(zipEntry);

                   //combine the file name and destination folder path
                   String fullZipToPath = Path.Combine(outFolder, entryFileName);
                   string directoryName = Path.GetDirectoryName(fullZipToPath);

                   using (FileStream streamWriter = File.Create(fullZipToPath))
                   {
                       StreamUtils.Copy(zipStream, streamWriter, buffer); //<<<< StreamUtils.Copy is NOT recognized
                   }
               }
           }
           finally
           {
               if (zf != null)
               {
                   zf.IsStreamOwner = true; //<<<< ZipFile zf.IsStreamOwner is NOT recognized
                   zf.Close();
               }
           }
       }
    }
}

 


Viewing all articles
Browse latest Browse all 1764

Trending Articles