Skip to content

Instantly share code, notes, and snippets.

@BrianMRO
Created November 18, 2020 20:54
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 BrianMRO/e4b9bbc91f758d9adf9a5f871e74d34e to your computer and use it in GitHub Desktop.
Save BrianMRO/e4b9bbc91f758d9adf9a5f871e74d34e to your computer and use it in GitHub Desktop.
UploadLabelControlFile
protected virtual bool UploadLabelControlFile(StringBuilder labelSB, string language)
{
byte[] labelBytes = Encoding.ASCII.GetBytes(labelSB.ToString());
// Define a unique filename for the label control file
string filename = "label-" +
Guid.NewGuid().ToString() +
"." +
language.ToLower();
// Create a FileInfo for the file byte array using the filename above
PX.SM.FileInfo labelFileInfo = new FileInfo(filename, null, labelBytes);
// Upload into Acumatica
UploadFileMaintenance upload = PXGraph.CreateInstance<UploadFileMaintenance>();
// If the upload was successful, print the file
if (upload.SaveFile(labelFileInfo))
{
DHPrint(labelFileInfo, printer);
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment