Skip to content

Instantly share code, notes, and snippets.

@jvanhoesen
Created March 28, 2022 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvanhoesen/609f1931b2d4040e8110736d163ad374 to your computer and use it in GitHub Desktop.
Save jvanhoesen/609f1931b2d4040e8110736d163ad374 to your computer and use it in GitHub Desktop.
Retrieving a file from ZipArchive
//Creates a stream from the specified file within the .ZIP file
using (Stream fileStream = zip.OpenRead(info.Name))
{
using(MemoryStream innerStream = new MemoryStream())
{
fileStream.CopyTo(innerStream);
//Create Acumatica file from .Zip file content
fileInfo = new PX.SM.FileInfo(info.Name, null, innerStream.ToArray());
//Saves file to Invoice
if (uploadFileMaint.SaveFile(fileInfo, FileExistsAction.CreateVersion))
{
PXNoteAttribute.AttachFile(Base.Document.Cache, Base.Document.Current, fileInfo);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment