By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,583 Members | 617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,583 IT Pros & Developers. It's quick & easy.

Create word doc from a memory stream NO file stream used

P: n/a
Guys

Is there a way in C# to create a word object directly from a memory
stream without passing that to hard disk (file stream). I think it
doesn't makes sense to create a file just to read it again in to word
object. If some one has some brilliant idea please share.

In a nutshell this is what I'm currently doing
ByteArray --File Stream --Word Object
and this I want to do
ByteArray --Memory Stream --Word Object
thanks
nitin

Jul 24 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Jul 24, 5:13*am, Nitin Mahajan <nitinhung...@gmail.comwrote:
Guys

Is there a way in C# to create a word object directly from a memory
stream without passing that to hard disk (file stream). I think it
doesn't makes sense to create a file just to read it again in to word
object. If some one has some brilliant idea please share.

In a nutshell this is what I'm currently doing
ByteArray --File Stream --Word Object
and this I want to do
ByteArray --Memory Stream --Word Object

thanks
nitin
There is a way. I've seen this in C++ code on somebody's blog a while
ago--it was too speed up the app for performance, as the bytearray was
streaming in from a port connected to the internet. I just don't have
a solution offhand right now. One way, however, that might work for
you is in the C#3.0 Cookbook (O'Reilly). Keywords: redirection,
RedirectStandardOutput property of the Process.StartInfo class, also
look to recipe 12.20, writing to multiple output files at one time.

Hope this helps...

RL
Jul 24 '08 #2

P: n/a
I did something similar to this. I created an xml document, not word
document, using the StringReader class. It creates a memory stream
from a string, and I was able to substitute it into anywhere a file
stream was required.
Hope this helps.
jake
On Jul 24, 8:13 am, Nitin Mahajan <nitinhung...@gmail.comwrote:
Guys

Is there a way in C# to create a word object directly from a memory
stream without passing that to hard disk (file stream). I think it
doesn't makes sense to create a file just to read it again in to word
object. If some one has some brilliant idea please share.

In a nutshell this is what I'm currently doing
ByteArray --File Stream --Word Object
and this I want to do
ByteArray --Memory Stream --Word Object

thanks
nitin
Jul 24 '08 #3

P: n/a
On Thu, 24 Jul 2008 05:13:41 -0700, Nitin Mahajan <ni**********@gmail.com>
wrote:
Guys

Is there a way in C# to create a word object directly from a memory
stream without passing that to hard disk (file stream). I think it
doesn't makes sense to create a file just to read it again in to word
object. If some one has some brilliant idea please share.

In a nutshell this is what I'm currently doing
ByteArray --File Stream --Word Object
and this I want to do
ByteArray --Memory Stream --Word Object
No "brilliant idea". Just replace your FileStream instance with a
MemoryStream instance, simple as that.

Ideally, your code would have created a FileStream but used it just as a
Stream. If so, it's a simple one-line change. If you declared your
stream usage as FileStream and then used something that's actually
declared only in the FileStream class, you might have a little extra
work. But that's probably not the case.

Pete
Jul 24 '08 #4

P: n/a
On Jul 24, 6:44*pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Thu, 24 Jul 2008 05:13:41 -0700,NitinMahajan<nitinhung...@gmail.com*
wrote:
Guys
Is there a way in C# to create a word object directly from a memory
stream without passing that to hard disk (file stream). I think it
doesn't makes sense to create a file just to read it again in to word
object. If some one has some brilliant idea please share.
In a nutshell this is what I'm currently doing
ByteArray --File Stream --Word Object
and this I want to do
ByteArray --Memory Stream --Word Object

No "brilliant idea". *Just replace your FileStream instance with a *
MemoryStream instance, simple as that.

Ideally, your code would have created a FileStream but used it just as a *
Stream. *If so, it's a simple one-line change. *If you declared your *
stream usage as FileStream and then used something that's actually *
declared only in the FileStream class, you might have a little extra *
work. *But that's probably not the case.

Pete
Pete

I dont think it will work because I'm currently using .net 1.1 and
they way the word object can be created is creating a word document
from a file stream and then using that word doc. Now the problem is I
dont want to create a word document physically on the hard disk. I
want to create the word object directly from bytearray as the word
document is stored as blob in database.

Also its a different case from creating XML as in .net there is
inbuilt support for XML but not for word.

I hope I'm clear this time. In anycase thanks for your help.

cheers
nitin
Jul 28 '08 #5

P: n/a
On Jul 28, 2:42*am, Nitin Mahajan <nitinhung...@gmail.comwrote:
>
I dont think it will work because I'm currently using .net 1.1 and
they way the word object can be created is creating a word document
from a file stream and then using that word doc.
Try upgrading to 3.0--the express version is free. Then try it and
see if it solves your problem.

RL
Jul 28 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.