how to set a file name and extension when insert ole object using MemoryStream?
example1:
var document = new Document();
var builder = new DocumentBuilder(document);
var shape = builder.InsertOleObject(“D:\1.zip”, false, true, null);
document.Save(“D:\testInsertZip.docx”);
example2:
var document = new Document();
var builder = new DocumentBuilder(document);
var bs = File.ReadAllBytes("D:\\1.zip");
using (var stream=new MemoryStream(bs))
{
var shape = builder.InsertOleObject(stream, "Package", true, null);
}
document.Save("D:\\testInsertZip2.docx");
in the example2, when clicking on icon, it asks for the application to open that embedded file.
I dont wan’t to save data to file, because there are many data need to handle, is there any other method to set the file name and extension of inserted stream, so the microsoft word can recognize the file format?
i saw the return shape.OleFormat has two properties: SuggestedExtension and SuggestedFileName may can do this, but they are readonly.