Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.