473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Create word doc from a memory stream NO file stream used

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
5 6833
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nicholas Then | last post by:
I am writing an ASP.NET application and I have a class that I have written to create a vCard...it just returns a string with all the necessarry info... Anyway...is there a way that I can create a...
5
by: Henry Jordon | last post by:
hello I was wondering if someone could help me get a main going on this project I've completed the header file that the professor started us on but not really sure how to get the main going. If...
3
by: JW | last post by:
I can encrypt the contents of a memory stream with no problems, however when decrypting( I'm using the same key an IV ) I get an exception stating bad data. I'm at a lost. I'm actually creating...
0
by: Federico | last post by:
Hi I want to create a Web Services where I receive a Template DOT word a file XML and with these I create a Document that a I'll Send as Dime Attachment. <WebMethod()> _ Public Function...
0
by: Federico | last post by:
Hi I want to create a Web Services where I receive a Template DOT word a file XML and with these I create a Document that a I'll Send as Dime Attachment. <WebMethod()> _ Public Function...
2
by: spidey12345 | last post by:
what i need this program to do is to read paragraphs like "st blah blh test ere se sit blha eere w" and then it will reformat to "st blah...
7
by: spidey12345 | last post by:
can anybody help me with this i have a baddata.txt file that has certain data like this: " blah blah ere werew ss a s ef df ww erew asf" and i...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
3
by: CSharper | last post by:
I have a resource file that i open to write.After writing almost 300MB I call the close method and It failed with out of memory. One thing I learned that, in C#, resource writers doesn't write data...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.