dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: problem in zipping image files using windows service

  1. #1
    Join Date
    Dec 2007
    Posts
    2

    problem in zipping image files using windows service

    I am using .Net 2003
    This code works fine in Windows Application.
    In Windows Application, I am able to zip the image files properly and it totally contains 900MB
    My problem is the same code which I used in my Windows Application,
    does not work while I run it with Windows services.
    In my Windows application I am able to zip the whole 900Mb without any problems,
    but in my windows services I am not able to zip the whole 900Mb.
    In Windows Services it throws an error :SystemOutOfMemoryException
    I am trying to zip all image files, example: idx,fim,rim
    Below is the code I am using:

    Please help me to find the solution to run this code properly in windows services as well.

    using Xceed.Compression;

    using Xceed.FileSystem;

    using Xceed.Zip;

    Xceed.Zip.Licenser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";

    public int MakeZipFile(string zipFileName, string[] filesToComp)
    {
    int retVal = 0;
    DiskFolder tempFolder = new DiskFolder();
    try
    {
    ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
    zip.TempFolder = tempFolder;
    try
    {
    zip.BeginUpdate();
    foreach( string file in filesToComp )
    {
    DiskFile fileToZip = new DiskFile( file );
    fileToZip.CopyTo( zip, true );
    ++retVal;
    }
    }
    finally
    {
    zip.EndUpdate();
    }
    }

    catch(Exception exec)
    {
    throw new ZipException(exec.Message);
    }
    finally
    {
    }
    return retVal;
    }
    }

    }

    // Windows Services --- main part of execution

    string zipfilepath="C:\\temp\\pollNew.zip"; // all my image files will be zipped in pollnew.zip
    string[] pFiles=new string[7]; // pFiles contains all files that I want to zip
    pFiles[0]="D:\\New\\121807\\00007069.FCI";
    pFiles[1]="D:\\New\\121807\\00007069.FI2";
    pFiles[2]="D:\\New\\121807\\00007069.FIM";
    pFiles[3]="D:\\New\\121807\\00007069.IDX";
    pFiles[4]="D:\\New\\121807\\00007069.RCI";
    pFiles[5]="D:\\New\\121807\\00007069.RI2";
    pFiles[6]="D:\\New\\121807\\00007069.RIM";
    MakeZipFile(string zipfilepath, string[] pFiles) // calling MakeZipFile Function Here

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,227

    Re: problem in zipping image files using windows service

    Check to make sure the account the service is running under has sufficient permissions to run the compression program and access the file system.

    [hint: Local System Account may not have sufficient permissions]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)