Open a File using openfiledialog...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • helloitsme
    New Member
    • Oct 2006
    • 20

    Open a File using openfiledialog...

    Hello!

    I am trying to open a file that is selected by a user from the openfiledialog box, but the file does not open. Below is the part of the code that does so...

    ............... ............... ............... ............... ........

    OpenFileDialog fdlg = new OpenFileDialog( );
    fdlg.Filter = "Text Files(*.txt)|*. txt";
    fdlg.RestoreDir ectory = true;
    if (fdlg.ShowDialo g() == DialogResult.OK )
    {
    // fdlg.OpenFile() ; //this does not open the selected file
    textBoxOutput.T ext = fdlg.FileName;
    fdlg.OpenFile() ; //this does not open the selected file

    }
    ............... ............... ............... ............... ...........


    Please help....

    Thank you....
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    fdlg.OpenFile() ; //this does not open the selected file

    What evidence do you have for that since you do not save the the stream returned by this method?

    Comment

    • helloitsme
      New Member
      • Oct 2006
      • 20

      #3
      Thank you for replying...

      According to what I understand from the description of the filedialog, the method openfile opens the file that is selected by the user in the dialog box of filedialog that appears...

      Please let me know if I understood something wrong...I am not sure what is to be saved for that to happen...

      Thnax..

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Originally posted by helloitsme
        According to what I understand from the description of the filedialog, the method openfile opens the file that is selected by the user in the dialog box of filedialog that appears...
        That is my understanding of the description to, however in your first post you have asserted that this doesn't happen but provided no evidence of that assertion.

        Code:
        stream^ instream = fdlg.OpenFile();

        Comment

        • helloitsme
          New Member
          • Oct 2006
          • 20

          #5
          Hello..Thanx for replying...

          well, I do not understand what you mean by evidence in this case....

          if you mean I need a stream reader or somthing, then I am able to read the file using a streamreader and then display the contents in a richtextbox. but what I want is that the file should open as it does when you open it up from the windows explorer....

          please let me know ....
          thanx again !

          Comment

          Working...