Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

Ahhh, today is saturday woke up little early (6:00 AM). Anyway, I went to ASP.NET forums to check out some questions and one developer asked "How can I write text to a word file.".

So, here is the code to write text to a word file:

private void WriteToWordFile() 
        {
            
// Any folder 
            
string path = @"C:\ServerFolder\MyWordFile.doc"; 
            
            
string text = TextBox2.Text; 
            
// Put it in try-catch finally :) 
            
FileStream fs =  File.Create(path);  
            fs.Close(); 
            StreamWriter sw = 
new StreamWriter(path); 
            sw.Write(text); 
            sw.Close(); 
        
        }

Okay me leaving for Job!

powered by IMHO

 

Posted on Saturday, October 8, 2005 8:12 AM | Back to top


Comments on this post: Writing text to a word file in ASP.NET

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Mohammad Azam | Powered by: GeeksWithBlogs.net