h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Display File Name path in ComboBox using C#.Net

"Display File Name path in Combobox using C#.Net"


addParentdirectoryFile Method
private void addParentdirectoryFile(string sourcePath)
{
string[] fileNames = Directory.GetFiles(sourcePath);
foreach (string str in fileNames)
{
comboBox1.Items.Add(str);
}
}
addChildDirectFiles Method
private void addChildDirectFiles(string sourcePath)
{
foreach (string subFolders in Directory.GetDirectories(sourcePath,"*",SearchOption.AllDirectories))
{
string[] subFolderfileNames = Directory.GetFiles(subFolders);
foreach (string fname in subFolderfileNames)
{
comboBox1.Items.Add(fname);
}
}
}
Call this method where you want:
addParentdirectoryFile();
addChildDirectFiles();