Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello every one.....

I have a situation..... i have a string.. so i need to convert that text into doc file then convert that into binary format and finally save that binary format in database.... this procees needs to be done in backgrond....
Posted
Comments
ridoy 11-Jan-13 1:45am    
So what do you want to do now?Where is your question?Where is your code?
Hemant Singh Rautela 11-Jan-13 1:55am    
Are you ordering to code project user to solve your task so that you can easily use it ..???
Very funny... :-)

First work/research yourself, then ask to help for, where you stuck.
[no name] 11-Jan-13 5:28am    
i am trying in this way...

string str = TextBox1.Text;
Word.Application wordApp = new Word.Application();
wordApp.Visible = true;
object objMissing = System.Reflection.Missing.Value;
Word.Document wordDoc = wordApp.Documents.Add(ref objMissing, ref objMissing, ref objMissing, ref objMissing);
Word.Paragraph wordParagraph = wordDoc.Paragraphs.Add(ref objMissing);
wordParagraph.Range.Text = str;
wordParagraph.Range.InsertParagraphAfter();


object fileName = "C:\\AutoGenerated.docx";
wordDoc.SaveAs(ref fileName,
ref objMissing, ref objMissing,
ref objMissing, ref objMissing,
ref objMissing, ref objMissing,
ref objMissing, ref objMissing,
ref objMissing, ref objMissing,
ref objMissing, ref objMissing,
ref objMissing, ref objMissing,
ref objMissing);

((Word._Document)wordDoc).Close(ref objMissing, ref objMissing, ref objMissing);
((Word._Application)wordApp).Quit(ref objMissing, ref objMissing, ref objMissing);
//string s = wordDoc.Content.Text;

byte[] b = File.ReadAllBytes("C:\\AutoGenerated.docx");
File.Delete("C:\\AutoGenerated.docx");




but here the .doc file is saved in the Physical memory.... How can i read that Doc file without saving it to the Drive....

First of all, if you mean Microsoft Word .doc, you are talking about obsolete format (as opposed to .docx). Besides, Word .doc documents do not fit Web applications well, as this is a proprietary format. However, such files are often used by Web applications; it's just wrong, but real life is real life.

Now, what to do? Here is what you can do in your particular case: write a regular text file and name it "something.doc". A text file, from the standpoint of the Word application, is "binary" enough :-) (did you know that everything is binary? :-)). The result of this is quite a legitimate text document for Word, it will be correctly opened and used. Sounds weird, but true. Don't make things more complex than they have to be.

—SA
 
Share this answer
 
Hi,

I am not giving you ready-made solution, I suggest you a process which can be easily achievable.You have to help yourself first.

"Just Convert Directly String to Binary, and then you can easily save it in database.... "

:-)



Asp.Net/C#.Net Help Blog[^]
Hemant Singh Rautela
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900