Katonas
Member
- Joined
- Sep 6, 2022
- Messages
- 6
- Programming Experience
- Beginner
Hello
I have listbox which contains ini failes from directories. Now I want be able to read and open selected file from listbox, but im having trouble doing it now.
My code atm.
I have listbox which contains ini failes from directories. Now I want be able to read and open selected file from listbox, but im having trouble doing it now.
My code atm.
C#:
private void Form1_Load(object sender, EventArgs e)
{
string rootdir = @"C:\Users\isaced1\Desktop\test";
string[] files = Directory.GetFiles(rootdir, "*.ini", SearchOption.AllDirectories);
//var folder = @"C:\Users\isaced1\Desktop\test\";
//var txtFiles = Directory.GetFiles(files, "*.ini");
Projects.Items.AddRange(files);
var items = Projects.SelectedItems;
foreach (var item in items)
{
string fileName = Projects.GetItemText(item);
string fileContents = System.IO.File.ReadAllText(fileName);
Process.Start(fileContents);
}
}
Last edited by a moderator: