Loading a byte array into a word document

  • Thread starter Thread starter Pete Mann
  • Start date Start date
P

Pete Mann

Hi,

Is there anyway to programmatically load a byte array into a word
document in c#?

We have an application that streams a byte array of a previously saved
word document into a c# client. I can file the stream away to the
local disk, then open with document.open, but there is a system
requirement to bypass saving to local disk on security grounds.

Thank you for any guidance,

Pete
 
LP said:
Look into MemoryStream Class.
......

Thank you for your reply. I've looked (and googled) on memorystream,
but I'm still not getting anywhere. I can now have the document
sitting in memory, but can't get it to load in word. Word has a
app.documents.open() method (requires file so no good).

I've been stabbing around with the following, with no result..

(if you assume fileBytes is a word document in a byte array)

MemoryStream mm = new MemoryStream(fileBytes);
mm.Seek(0x0,SeekOrigin.Begin);

//this doesn't work
wordDoc=(Word.Document)mm.CreateObjRef(wordDoc.GetType());

//this doesn't work
wordDoc =(Word.Document)mm;

I'm sorry to be a pain, but could you give a little more insight? I'm
fairly new to c# and I'm no doubt missing a huge chunk of
understanding. To be clear again – I have a Microsoft Word Document in
a byte array, I need it to be loaded into Microsoft word without
filing it away and reading it back in again.

Thanks again for your patience,

Pete
 
Back
Top