Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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?

Reply With Quote
  #2 (permalink)  
Old October 31st, 2004, 08: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 Send a message via Skype™ to melvik
Default

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

Always:),
Hovik Melkomian.
Reply With Quote
  #3 (permalink)  
Old November 4th, 2004, 03: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.:)
Reply With Quote
  #4 (permalink)  
Old November 4th, 2004, 03: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.:)
Reply With Quote
  #5 (permalink)  
Old November 5th, 2004, 01: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
Reply With Quote
  #6 (permalink)  
Old November 5th, 2004, 03: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.:)
Reply With Quote
  #7 (permalink)  
Old November 5th, 2004, 05: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
Reply With Quote
  #8 (permalink)  
Old November 5th, 2004, 06: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.:)
Reply With Quote
  #9 (permalink)  
Old November 7th, 2004, 11:34 PM
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
here is my code c++ file handling amahja56 C++ Programming 2 November 23rd, 2007 06: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 01:57 PM
c++ file handling. amahja56 C++ Programming 2 March 23rd, 2005 06:13 PM



All times are GMT -4. The time now is 07:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.