Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 16th, 2004, 05:05 AM
Registered User
 
Join Date: Oct 2004
Location: KOLKATA, WB, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default FILE HANDLING

HOW CAN WE READ A WORD DOCUMENT AND SHOW IT IN A TEXTBOX?

 
Old October 31st, 2004, 09:35 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

I'd happy too, if anyone gives an idea!

Always:),
Hovik Melkomian.
 
Old November 4th, 2004, 04:40 PM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hello,
Take a look at this example,
Code:
     using System.Text; 
     using System.IO; 
     .... 
     private void button1_Click(object sender, System.EventArgs e) 
     { 
          OpenFileDialog dlg = new OpenFileDialog(); 
          dlg.Title = "Open text file" ; 
          dlg.InitialDirectory = @"c:\" ; 
          dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;  
          if(dlg.ShowDialog() == DialogResult.OK) 
          { 
               StreamReader sr = File.OpenText(dlg.FileName); 
               string s = sr.ReadLine(); 
               StringBuilder sb = new StringBuilder();  
               while (s != null) 
               { 
                    sb.Append(s);  
                    s = sr.ReadLine(); 
               }  
               sr.Close(); 
               textBox1.Text = sb.ToString();  
          }  
     }
--------------------------------------------
Mehdi.:)
 
Old November 4th, 2004, 04:46 PM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

very good link for working on TextBoxes,
http://www.syncfusion.com/FAQ/WinForms/FAQ_c94c.asp


--------------------------------------------
Mehdi.:)
 
Old November 5th, 2004, 02:03 AM
Friend of Wrox
 
Join Date: Feb 2004
Location: Bangalore, Karnataka, India.
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Mehdi62b I think you are telling about opening a txt document and what they need is opening a Word Document in .NET.

I have solution for that, the code below will open the Word Document file, reads text from it and display it on the textBox

Before writing the code add a refrence to the "Microsoft Word Object Library"
in the "COM" tab of Add Reference menu option

Code
****

object fileName = @"C:\test.DOC";
object readOnly = false;
object isVisible = true;

object missing = System.Reflection.Missing.Value; // To handle unecessary params
Word.ApplicationClass oWordApp = new Word.ApplicationClass();
Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing,ref missing,ref missing, ref missing);

textBox1.Text = oWordDoc.Content.Text.ToString ();

Hope this helps :-)


It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old November 5th, 2004, 04:26 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

is there any much difference between DOC or TXT(for writing to TextBoxes!)?
both of them are Text files(like HTML,ASPX,...).

--------------------------------------------
Mehdi.:)
 
Old November 5th, 2004, 06:53 AM
Friend of Wrox
 
Join Date: Feb 2004
Location: Bangalore, Karnataka, India.
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes there are lot of difference between an ordinary text files and doc files. txt files store only the text, but word can store text, images and other ole objects etc., Also its stores lot of formating information with the text.


It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old November 5th, 2004, 07:35 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ya,okay,
I dont know whether we can print the pics and formatting information within a TextBox?!

--------------------------------------------
Mehdi.:)
 
Old November 8th, 2004, 12:34 AM
Friend of Wrox
 
Join Date: Feb 2004
Location: Bangalore, Karnataka, India.
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't think we can display images in text box, but some formatted text can be.


It is not how much we do,
but how much love we put in the doing.

-Mother Theresa




Similar Threads
Thread Thread Starter Forum Replies Last Post
here is my code c++ file handling amahja56 C++ Programming 2 November 23rd, 2007 07:25 AM
File strorage handling using JSP draggy Pro JSP 4 July 30th, 2006 12:44 PM
File handling vijayma VB How-To 3 June 7th, 2006 01:30 AM
FILE HANDLING yojeiram_n1 C++ Programming 2 March 13th, 2006 02:57 PM
c++ file handling. amahja56 C++ Programming 2 March 23rd, 2005 07:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.