Hi All,
I have a requirement where I have to download multiple (attachments from the purchase orders )files in a zipped folder.
I have almost completed the activity but the problem is that for some files only the files are getting corrupted.For the rest of the files things are ok.Could you please see in the code below where I am going wrong.
ZipFileName := 'Attachments_' + Format(CurrentDateTime) + '.zip';
DataCompression.CreateZipArchive();
docAttached.Reset();
docAttached.SetRange(JobNo, Rec."Job No.");
docAttached.SetRange(JobTaskNo, Rec."Job Task No.");
docAttached.SetRange("Table ID", 122);
docAttached.SetRange("No.", docno);
if docAttached.FindSet() then begin
Page.Run(1173, docAttached);
repeat
TempBlob.CreateOutStream(DocumentStream);
RecRef.GetTable(docAttached);
FldRef := RecRef.Field(docAttached.FieldNo("No."));
FldRef.SetRange(docAttached."No.",);
if RecRef.FindSet() then begin
repeat
TempBlob.CreateInStream(IStream);
docAttached."Document Reference ID".ExportStream(DocumentStream);
FullFileName := Format(docAttached."File Name" + '.' + docAttached."File Extension");
DataCompression.AddEntry(IStream, FullFileName);
until RecRef.Next() = 0;
end;
until docAttached.Next() = 0;
Tempblob.CreateOutStream(DocumentStream);
DataCompression.SaveZipArchive(DocumentStream);
TempBlob.CreateInStream(IStream);
DownloadFromStream(IStream, '', '', '', ZipFileName);
end;
Your help is much appreciated,
Thank you.