Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Open File Dialog Box

Status
Not open for further replies.

jriggs420

Programmer
Sep 30, 2005
116
US
Hi All,

I'm totally new to OO programming, well more precisely microsoft .net style syntax. I recently downloaded Visual c# express, I want to learn, but am having a difficult time getting started. Mainly I think I'm searching the wrong terms. My first goal is to open a word doc in my application. After that I'll be parsing some data out of it, and generating a .txt file. So my first questions are:

Should I be using the RichTextBox to display the word doc?
If so, this line is giving me issues
Code:
private void btnOpen_Click(object sender, EventArgs e)
        {
            if (ofdDoc.ShowDialog() == DialogResult.OK)
            {
                rtbData.Text = Text.FromFile(ofdDoc.FileName);
            }
        }
'string' does not contain a definition for 'FromFile'
I know this is easy for the pros, but I need somewhere to start. Also, any links to sample code/prog/resources would be great. I have the SAMS 24 hour book, but I don't like it... TIA-

Joe

Because a thing seems difficult for you, do not think it impossible for anyone to accomplish.
Marcus Aurelius
 
Update:

So after digging through the the help section I found this code
Code:
if(openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    // Load the contents of the file into a RichTextBox control:
    rtbData.LoadFile(openFile1.FileName,
    RichTextBoxStreamType.PlainText)
Which works, but I 'm getting all the formatting garbage inherent in .doc files. Is there a better way to view .docs in a c# app?

Because a thing seems difficult for you, do not think it impossible for anyone to accomplish.
Marcus Aurelius
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top