?
Solved

Issue using ICSharpCode.SharpZipLib to get zipped file contents of a file within the Citrix enviroment

Posted on 2009-05-11
3
Medium Priority
?
426 Views
Last Modified: 2012-06-27
I have an application which uses the ICSharpZipLib.dll. I have code within which returns the number of compressed files within a zip file.  In the development environment, (non Citrix), the code returns the correct amout of files. Within the Citrix environment, it returns the number of files one would be able to access if using Winzip, which is far less than the actual number of compressed files for a large zip file. The actually number of compressed files in this instance is 120,243.

I am unsure of how to troubleshoot this to get the correct number of files. If anyone has any suggestions, my thanks to you in advance.
0
Comment
Question by:CultLeaderZero
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24363397
What version of .NET do you have?  With 2.0 and higher, there is a way to access a .zip file with native Java-wrapper code.
0
 

Author Comment

by:CultLeaderZero
ID: 24363909
The .NET version is 2.0.50727 SP1.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 24364408
Proof-of-concept:


// Add a .NET reference to vjslib to the project. 
 
// Source:
//  http://www.c-sharpcorner.com/UploadFile/neo_matrix/SharpZip04242007001341AM/SharpZip.aspx
 
using java.io;
using java.util;
using java.util.zip;
using System;
using System.IO;
using System.Collections.Generic;
 
public class PkZip
{
 
    /// <summary> 
    /// Create a zip file from a list of files. 
    /// </summary> 
    /// <param name="zipFileName">Output zip file name.</param> 
    /// <param name="sourceFiles">List of file names to include.</param> 
    public static void Zip(string zipFileName, List<string> sourceFiles)
    {
        // Create an output zip file. 
        FileOutputStream filOpStrm = new FileOutputStream(zipFileName, false);
        ZipOutputStream zipOpStrm = new ZipOutputStream(filOpStrm);
 
        // Add the files by reading from the input file, and writing through the 
        // Zip compression routines. 
        foreach (string strFilName in sourceFiles)
        {
            FileInputStream filIpStrm = new FileInputStream(strFilName);
            ZipEntry ze = new ZipEntry(Path.GetFileName(strFilName));
 
            zipOpStrm.putNextEntry(ze);
 
            sbyte[] buffer = new sbyte[1024];
 
            int len = 0;
 
            // Continue to write the buffer until the end of the data. 
            while (len >= 0)
            {
                len = filIpStrm.read(buffer);
                if (len >= 0)
                    zipOpStrm.write(buffer, 0, len);
            }
 
            filIpStrm.close();
        }
 
        // Close the streams. 
        zipOpStrm.closeEntry();
        zipOpStrm.close();
        filOpStrm.close();
    }
 
 
    /// <summary> 
    /// Extract the files from a zip file to a destination folder. 
    /// </summary> 
    /// <param name="zipFileName">The name of the zip file</param> 
    /// <param name="destinationPath">The destination folder for the extracted files.</param> 
    public static void Unzip(string zipFileName, string destinationPath)
    {
        ZipFile zipfile = new ZipFile(zipFileName);
        List<ZipEntry> zipFileList = GetZipFiles(zipfile);
 
        foreach (ZipEntry file in zipFileList)
        {
            if (!file.isDirectory())
            {
                InputStream s = zipfile.getInputStream(file);
                try
                {
                    string fileName = file.getName();
                    string directoryName = Path.Combine(destinationPath, Path.GetDirectoryName(fileName));
 
                    if (!Directory.Exists(directoryName))
                        Directory.CreateDirectory(directoryName);
 
                    string outputName = Path.Combine(directoryName, Path.GetFileName(fileName));
                    FileOutputStream dest = new FileOutputStream(outputName);
                    try
                    {
                        int len = 0;
                        sbyte[] buffer = new sbyte[7168];
                        while (len >= 0)
                        {
                            len = s.read(buffer);
                            if (len >= 0)
                            {
                                dest.write(buffer, 0, len);
                            }
                        }
                    }
                    finally
                    {
                        dest.close();
                    }
                }
                finally
                {
 
                    s.close();
                }
            }
        }
    }
 
    private static List<ZipEntry> GetZipFiles(ZipFile zipfil)
    {
        List<ZipEntry> lstZip = new List<ZipEntry>();
        Enumeration zipEnum = zipfil.entries();
        while (zipEnum.hasMoreElements())
        {
            ZipEntry zip = (ZipEntry)zipEnum.nextElement();
            lstZip.Add(zip);
        }
 
        return lstZip;
    }
 
}

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question