Welcome to the Xceed Community Sign in | Join | Help
Community Search  

problem adding folders to zip file

Sort Posts: Previous Next
  •  02-25-2008, 6:16 AM Post no. 5755

    problem adding folders to zip file

    hi, i am using this code to add multiple files and folders in a zip file. the files are added properly but upon adding folders, i get return value 526 which is the error code for a warning. and the folders are not added to the zip file.

    try
    try
    xZip := TXceedZip.Create(nil);

    for I := 0 to totalFiles - 1 do
    begin
    if Length(strArray[I]) > 0 then
    begin
    if itIsDirectory(strArray[I]) then
    xZip.AddFilesToProcess(strArray [I] + '\')
    else
    xZip.AddFilesToProcess(strArray [I]);
    end;
    end;

    with xZip do begin
    License(OUR_LICENSE_KEY);
    ZipFilename := dstPath;
    PreservePaths := false;//savePath;
    CompressionLevel := 1;
    ProcessSubfolders := false;
    Result := Zip;
    end;

    if Result <> 0 then
    //log the error code
    finally
    xZip.Free;
    end;

    except
    on Error: Exception do
    //log the error message
    end;

    the value of xZip.FilesToProcess before calling xZip.zip is like

    'F:\crap\WallPapers\Airfield.jpg'#$D#$A'F:\crap\WallPapers\100 dollar bills.jpg'#$D#$A'F:\crap\one folder\'

    before calling the Zip function.

    (I am using delphi 2007)
  •  02-26-2008, 6:12 AM Post no. 5756 in reply to 5755

    Re: problem adding folders to zip file

    can anyone tell me how i can capture a warning event?
  •  02-26-2008, 11:44 AM Post no. 5757 in reply to 5755

    Re: problem adding folders to zip file

    I suggest that you take a look at the Delphi GettingStarted sample that should be installed with the package (C:\Xceed Component Samples\Xceed Zip Compression Library 6.1\Samples\Delphi 4-7\GettingStarted).

    It should look something like that:

    <code>
    procedure xZipWarning(Sender: TObject; const sFilename: WideString;
    xWarning: TOleEnum);

    {...}

    { OnWarning event:
    Triggered during processing when a recoverable error is encountered. }
    procedure TfrmMain.xZipWarning(Sender: TObject;
    const sFilename: WideString; xWarning: TOleEnum);
    begin
    edtResults.Lines.Add( 'Warning ' + IntToStr( xWarning ) );
    end;
    </code>
    Charles Bérubé-Rémillard
    Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.