Xancholy

I have a TabControl on which I would like to display the contents of each subfolder in a folder called MyFolder in Application.StartupPath

So if the user creates a subfolder called Folder1, then on Tabcontrol1 there would a tabpage called Folder1.

Basically, foreach subfolder in Application.StartupPath + "\MyFolder"... show a tabpage called subfolderName.

Thanks for any help to figure this out.


Re: Visual C# Express Edition A tabpage for each folder in Application.StartupPath

cverdon

Hi,

You are looking for something like this:

string[] folders = Directory.GetDirectories( Application.StartupPath );

foreach (string folder in folders) {

TabPage page = new TabPage(Path.GetFileName(folder));

this.tabControl1.TabPages.Add( page );

Button btn = new Button();

btn.Text = Path.GetFileName( folder );

page.Controls.Add( btn );

}

Charles





Re: Visual C# Express Edition A tabpage for each folder in Application.StartupPath

Xancholy

Beautiful. Thanks Charles for that working code. Just a note that Using System.IO; should be added to namespaces.