Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Problem using MemoryFolder for fast unzipping

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20034 |

    Hi,

    We’re evaluating the Xceed components with C# 3.5.
    Please help with two problems so we can evaluate your product:

    Question 1:

    I’m trying to use the memory folder for fast unzipping.
    This code works ok when I call it directly from a Console Application, but I get this exception when I use it in a web service:

    Test method Tests.WSTester.WSUnzip threw exception:  System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. —> Xceed.FileSystem.ItemDoesNotExistException: Cannot perform the requested operation on an item that does not exist.
    Type: Xceed.FileSystem.MemoryFolder
    FullName: RAM_Drive:\folder\
       at Xceed.FileSystem.AbstractFolder.GetFiles(FileSystemEvents events, Object userData, Boolean recursive, Object[] filters)
       at Xceed.FileSystem.AbstractFolder.GetFiles(Boolean recursive, Object[] filters)
       at UTILITIES.ZipUtilXceed.UnZip(String zipFileName, String dstDir)
       at UTILITIES.ZipUtil.UnZip(String zipFileName, String dstDir)
       at ServerFacade.WSInterface.UnZip(String zipFileName, String dstDir) in d:\BDev\WSInterface.asmx.cs:line 370
       — End of inner exception stack trace —.

    The code:
    public override void UnZip(string realZipFileName, string dstDir)
            {
                Logger.Log(“StartMethod: ZipUtilXceed Unzip: got zip file <” + zipFileName +
                    “>”, SeverityLevelEnum.INFORMATION);

                if (!File.Exists(realZipFileName))
                {
                    Logger.Log(“ZipUtilXceed Unzip: zip file doesn’t exist – <” +
                        realZipFileName + “>”, SeverityLevelEnum.ERROR);
                    return;
                }

                if (!Directory.Exists(dstDir))
                    Directory.CreateDirectory(dstDir);
                try
                {
                    if (!Directory.Exists(dstDir))
                        Directory.CreateDirectory(dstDir);
                    ZipArchive zip = new ZipArchive(new DiskFile(zipFileName));
                    {
                        MemoryFolder memFolder = new MemoryFolder(“RAM_Drive”, “folder”);

                        zip.CopyFilesTo(memFolder, true, true);
                        foreach (MemoryFile memFile in memFolder.GetFiles(false, null))
                        {
                            string fixedExtractedFileName = fixSpecialCharsInFileName(memFile.Name);
                            string extractedDiskFileName = dstDir + Path.DirectorySeparatorChar +
                                fixedExtractedFileName; // These 2 lines – just replacing characters in the file-names
                            DiskFile extractedDiskFile = new DiskFile(extractedDiskFileName);
                            memFile.CopyTo(extractedDiskFile, true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                    throw ex;
                }
            }

    Note1:
    This code always works in the Web-Service:
    Xceed.Zip.QuickZip.Unzip(realZipFileName, dstDir, “*”);

    Question 2:
    Sometimes the ZIP file we unzipped cannot be deleted after we call our UnZip method (code in Question 1) and we get the error “file is used by another process”.
    How to “dispose” or “close” the zip file?
    None of your objects has Close, Flush or Dispose methods, and we can’t use them in a C# using(…) statement.

    Thanks for your help!

    Imported from legacy forums. Posted by O (had 1651 views)

    User (Old forums)
    Member
    Post count: 23064

    1- This is most likely because the web service cannot access the RAM. The exception suggest that : “System.Web.Services.Protocols.SoapException: SERVER was unable to process request”.

    The QuickZip() method works because there is no RAM access in the process.

    2- You can use ZipArchive.Delete to accomplish this.

    Imported from legacy forums. Posted by André (had 337 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

     Your answer didn’t help, I solved it myself:

    MemoryFolder x = new MemoryFolder (“RAMDrive1”, @”\Zip”);

     

    Thanks anyway.

    Imported from legacy forums. Posted by O (had 1421 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.