Connecting Tech Pros Worldwide Help | Site Map

Create word doc from a memory stream NO file stream used

Nitin Mahajan
Guest
 
Posts: n/a
#1: Jul 24 '08
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

raylopez99
Guest
 
Posts: n/a
#2: Jul 24 '08

re: Create word doc from a memory stream NO file stream used


On Jul 24, 5:13*am, Nitin Mahajan <nitinhung...@gmail.comwrote:
Quote:
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
jake
Guest
 
Posts: n/a
#3: Jul 24 '08

re: Create word doc from a memory stream NO file stream used


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:
Quote:
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
Peter Duniho
Guest
 
Posts: n/a
#4: Jul 24 '08

re: Create word doc from a memory stream NO file stream used


On Thu, 24 Jul 2008 05:13:41 -0700, Nitin Mahajan <nitinhungama@gmail.com>
wrote:
Quote:
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
Nitin Mahajan
Guest
 
Posts: n/a
#5: Jul 28 '08

re: Create word doc from a memory stream NO file stream used


On Jul 24, 6:44*pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
Quote:
On Thu, 24 Jul 2008 05:13:41 -0700,NitinMahajan<nitinhung...@gmail.com*
wrote:
>
Quote:
Guys
>
Quote:
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.
>
Quote:
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
raylopez99
Guest
 
Posts: n/a
#6: Jul 28 '08

re: Create word doc from a memory stream NO file stream used


On Jul 28, 2:42*am, Nitin Mahajan <nitinhung...@gmail.comwrote:
Quote:
>
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
Closed Thread


Similar C# / C Sharp bytes