Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active May 3, 2019 15:56
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 GroupDocsGists/bd45b1eb0a74ffab7eaa6a902e1de38a to your computer and use it in GitHub Desktop.
Save GroupDocsGists/bd45b1eb0a74ffab7eaa6a902e1de38a to your computer and use it in GitHub Desktop.
Render Files in ZIP as Attachments
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET
// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.StoragePath = @"C:\storage";
string guid = "attachment.zip";
// Create image handler object
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
// Create attachment object
Attachment attachment = new Attachment(guid, "foldername\document.docx", "document.docx");
// Get attachment original file and print out Stream length
using (FileContainer fileContainer = imageHandler.GetFile(attachment))
{
// You can save the file or render it as HTML pages or images
Console.WriteLine("Attach stream lenght: {0}", fileContainer.Stream.Length);
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET
// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.StoragePath = @"C:\storage";
string guid = "attachment.zip";
// Create image handler object
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
// Create attachment object and print out its name and file type
Attachment attachment = new Attachment(guid, "foldername\document.docx", "document.docx");
Console.WriteLine("Attach name: {0}, Type: {1}", attachment.Name, attachment.FileType);
// Get attachment original file using document stream
using (FileStream fileStream = new FileStream("attachment.zip", FileMode.Open))
using (FileContainer fileContainer = imageHandler.GetFile(fileStream, attachment))
{
// You can save the file or render it as HTML pages or images
Console.WriteLine("Attach stream lenght: {0}", fileContainer.Stream.Length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment