Last active
May 3, 2019 15:56
-
-
Save GroupDocsGists/bd45b1eb0a74ffab7eaa6a902e1de38a to your computer and use it in GitHub Desktop.
Render Files in ZIP as Attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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