Home | Articles|Namespace|Interview Questions|Tools|Jobs|Projects|Community
Asp.net Tutorials

»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books

»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects

»Competition
Community
Winners
Prizes
Write For Us
Members

»Other Resources
Links
Dotnet Resources


Forums»C# .NET »



Reading MS Word file in c#

How i read (word by word ---- or ---- line by line)MS word file's data through C#
posted by:anonymous on 5/7/2007 12:00:00 AM
Read a Word File using C#

You will need to use the StreamReader object to read the Word File using C#.

using System.IO;

string filename = Server.MapPath("..\\Temp\\Documents\\Word.doc";
StreamReader sr = new StreamReader(filename.ToString());
string Line = "";
Line = sr.ReadToEnd();
sr.Close();

You can also use the StreamWriter object to write to a new file.
string newfile = Server.MapPath("..\\Temp\\Documents\\NewFile\\NewWord.doc";
StreamWriter sw = new StreamWriter(newfile.ToString());
sw.Write(Line);
sw.Close();

if you need additional information on how the StreamReader and StreamWriter objects work check them out on MSDN at
http://msdn2.microsoft.com/en-us/library/system.io.streamreader.aspx
http://msdn2.microsoft.com/en-us/library/aa328965(VS.71).aspx

Nathan
posted by:Nathan  on 5/8/2007 12:00:00 AM
© 2008 dotnetwatch.com -- Privacy policy

Website Design & Internet Marketing by Shivam