Click to See Complete Forum and Search --> : listbox items


xobx
August 30th, 2006, 08:14 AM
when i start my application i want the listbox to take all the folder names in c:\items

so if c:\items contains the folders d2, d3, d4 etc

will the listbox have d2, d3, d4 in it when i start my program
and if i exit my program and create a new folder called s7 in c:\items\ will s7 be in the listbox also when i start my porgram again

anyone know how to do that?

creatorul
August 30th, 2006, 09:14 AM
Try this :

namespace WindowsApplication5

{



public partial class Form1 : Form

{

private DirectoryInfo dirInf;

public Form1()

{

InitializeComponent();

dirInf = new DirectoryInfo(@"c:\items");

foreach (DirectoryInfo dir in dirInf.GetDirectories())

listBox1.Items.Add(dir.Name);



}

}

}

xobx
August 30th, 2006, 10:37 AM
it doesnt work :S

example pls

creatorul
August 30th, 2006, 10:55 AM
Open WindowsApplication5.sln then compile . You have the code attached to this reply.

xobx
August 30th, 2006, 11:07 AM
Open WindowsApplication5.sln then compile . You have the code attached to this reply.

*wrong*

creatorul
August 30th, 2006, 12:27 PM
I'm sorry , I patched other code.
Try this one.

xobx
August 30th, 2006, 02:09 PM
now its work perfect! Thaaanks :)