Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. help

help

Scheduled Pinned Locked Moved C#
helptutorial
7 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sarojkumarjena
    wrote on last edited by
    #1

    I want to open a text file so I am using this code OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\" ; openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; But my application contains a richtextbox where I want to show the contents of the file How to do it

    T 1 Reply Last reply
    0
    • S sarojkumarjena

      I want to open a text file so I am using this code OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\" ; openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; But my application contains a richtextbox where I want to show the contents of the file How to do it

      T Offline
      T Offline
      trannguyen86
      wrote on last edited by
      #2

      Your question not specify what do you want to do please add more info in to your question! add:You have bad title!!

      S 1 Reply Last reply
      0
      • T trannguyen86

        Your question not specify what do you want to do please add more info in to your question! add:You have bad title!!

        S Offline
        S Offline
        sarojkumarjena
        wrote on last edited by
        #3

        When I will click the open menu dialog box will appear where I will browse the text file.And contets of the text file will be shown in the richtextbox which the application contains

        A 1 Reply Last reply
        0
        • S sarojkumarjena

          When I will click the open menu dialog box will appear where I will browse the text file.And contets of the text file will be shown in the richtextbox which the application contains

          A Offline
          A Offline
          AB7771
          wrote on last edited by
          #4

          After the user selects the text file from the OpenFile dialog use the richtextbox.loadFile() method and specify the filename in the method.

          Thanks & Regards, Pramod "Everyone is a genius at least once a year"

          S 1 Reply Last reply
          0
          • A AB7771

            After the user selects the text file from the OpenFile dialog use the richtextbox.loadFile() method and specify the filename in the method.

            Thanks & Regards, Pramod "Everyone is a genius at least once a year"

            S Offline
            S Offline
            sarojkumarjena
            wrote on last edited by
            #5

            But how to store the selected file name at run time,so that I can pass the parameter to load File method

            C S 2 Replies Last reply
            0
            • S sarojkumarjena

              But how to store the selected file name at run time,so that I can pass the parameter to load File method

              C Offline
              C Offline
              Chatura Dilan
              wrote on last edited by
              #6

              if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { richTextBox1.LoadFile(openFileDialog1.FileName); } You can store FileName in registry

              Chatura Dilan SC Java Programmer

              1 Reply Last reply
              0
              • S sarojkumarjena

                But how to store the selected file name at run time,so that I can pass the parameter to load File method

                S Offline
                S Offline
                saqib82
                wrote on last edited by
                #7

                u can use a global variable to store the name of selected file (at the event the file is being selected) and then use that variable to pass it to the method. sAqIb

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups