void ExportFile(VouchersClient voucher, ZipOutputStream zipOutputStream) { byte[] attachment = voucher.Buffer; voucher._Data = null; voucher._LoadedData = null; if (attachment == null) { if (voucher._Url != null) { try { if (voucher.IsWebUrl) { #if !SILVERLIGHT attachment = new WebClient().DownloadData(voucher._Url); var ext = System.IO.Path.GetExtension(voucher._Url); if (ext != null) { voucher._Fileextension = DocumentConvert.GetDocumentType(DocumentConvert.GetExtension(ext)); } #endif } else { #if SILVERLIGHT attachment = UtilFunctions.LoadFile(voucher._Url); #else attachment = UtilFunctions.LoadFile(voucher._Url).GetAwaiter().GetResult(); #endif } if (attachment == null) { return; } } catch { return; } } else { return; } } // Write the data to the ZIP file var sb = StringBuilderReuse.Create(voucher._Text).Replace('/', '-').Replace('\\', '-'); sb.Append('_').Append(voucher.RowId).Append('.').Append(Enum.GetName(typeof(FileextensionsTypes), IdObject.get((byte)voucher._Fileextension))); var name = sb.ToStringAndRelease(); zipOutputStream.PutNextEntry(new ZipEntry(name)); zipOutputStream.Write(attachment, 0, attachment.Length); WriteLogLine(string.Format(Uniconta.ClientTools.Localization.lookup("ExportingFile"), name)); }