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. how to use openFileDialog

how to use openFileDialog

Scheduled Pinned Locked Moved C#
helptutorial
4 Posts 2 Posters 0 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.
  • V Offline
    V Offline
    veluru krishna
    wrote on last edited by
    #1

    Hi all, how to open a text file

    Don't wait to hear a word of thanks from anybody when you help them instead ask them to help three other people and ask them to continue in chain.

    C 1 Reply Last reply
    0
    • V veluru krishna

      Hi all, how to open a text file

      Don't wait to hear a word of thanks from anybody when you help them instead ask them to help three other people and ask them to continue in chain.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Google is broken where you live ? here

      V 1 Reply Last reply
      0
      • C Christian Graus

        Google is broken where you live ? here

        V Offline
        V Offline
        veluru krishna
        wrote on last edited by
        #3

        hi, I know how to browse a file and read the data from the file into a richtextbox in windowsform but my problem is I am not able print each file as it is but I am able to print just as appending to each line using the following code: code : 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(); this.richTextBox1.Text = sb.ToString(); } can you please help me to read file as it is with newline characters to richtexbox

        Don't wait to hear a word of thanks from anybody when you help them instead ask them to help three other people and ask them to continue in chain.

        C 1 Reply Last reply
        0
        • V veluru krishna

          hi, I know how to browse a file and read the data from the file into a richtextbox in windowsform but my problem is I am not able print each file as it is but I am able to print just as appending to each line using the following code: code : 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(); this.richTextBox1.Text = sb.ToString(); } can you please help me to read file as it is with newline characters to richtexbox

          Don't wait to hear a word of thanks from anybody when you help them instead ask them to help three other people and ask them to continue in chain.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          veluru krishna wrote:

          while (s != null) { sb.Append(s); sb.Append(Environment.NewLine); s = sr.ReadLine(); }

          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