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. ListView list importing from .txt/ini file?

ListView list importing from .txt/ini file?

Scheduled Pinned Locked Moved C#
questiontutorial
4 Posts 3 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.
  • S Offline
    S Offline
    Sylenze
    wrote on last edited by
    #1

    Hey, i have a question... I'm writing a program, it goes like the following: it reads every line in the txt file as one option, and you can select those options, let's say the resolution of, and after that it writes the value to another file (a settings.ini for example), then boots the specified program with that changed value. it's like: Settings.txt: 640x320 800x600 1024x768 1200x1024 1600x1200 and so on. now how can i make the .txt file be shown in the listview, and how can i define every line as 1 option?

    E L 2 Replies Last reply
    0
    • S Sylenze

      Hey, i have a question... I'm writing a program, it goes like the following: it reads every line in the txt file as one option, and you can select those options, let's say the resolution of, and after that it writes the value to another file (a settings.ini for example), then boots the specified program with that changed value. it's like: Settings.txt: 640x320 800x600 1024x768 1200x1024 1600x1200 and so on. now how can i make the .txt file be shown in the listview, and how can i define every line as 1 option?

      E Offline
      E Offline
      Eduard Keilholz
      wrote on last edited by
      #2

      This should come close.... StreamReader sr = new StreamReader("path\to\file", FileMode.Open); // loop through the file using sr.ReadLine(); string sLine = sr.ReadLine(); bool Loop = (sLine.Length > 0); while (Loop) { ListItem li = new ListItem(sLine); _listName_.Items.Add(li); sLine = sr.ReadLine(); Loop = (sLine.Length > 0); } sr.Close();

      .: I love it when a plan comes together :. http://www.zonderpunt.nl

      S 1 Reply Last reply
      0
      • E Eduard Keilholz

        This should come close.... StreamReader sr = new StreamReader("path\to\file", FileMode.Open); // loop through the file using sr.ReadLine(); string sLine = sr.ReadLine(); bool Loop = (sLine.Length > 0); while (Loop) { ListItem li = new ListItem(sLine); _listName_.Items.Add(li); sLine = sr.ReadLine(); Loop = (sLine.Length > 0); } sr.Close();

        .: I love it when a plan comes together :. http://www.zonderpunt.nl

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

        FileMode.Open is an inacceptable overload =x

        1 Reply Last reply
        0
        • S Sylenze

          Hey, i have a question... I'm writing a program, it goes like the following: it reads every line in the txt file as one option, and you can select those options, let's say the resolution of, and after that it writes the value to another file (a settings.ini for example), then boots the specified program with that changed value. it's like: Settings.txt: 640x320 800x600 1024x768 1200x1024 1600x1200 and so on. now how can i make the .txt file be shown in the listview, and how can i define every line as 1 option?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, this will get you started:

          string[] stringArray=File.ReadAllLines(@"path\to\file");

          :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


          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