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