I am trying to upload folders to comboBox 1 from the directory, and then at selection from comboBox 1 to comboBox2.
I have below code, I am getting error when I make selection from comboBox 1 as direcory doesnot exists at bin/debug path of the project.
private void Form1_Load(object sender, EventArgs e)
{
DirectoryInfo di = new DirectoryInfo(@"\\Path\CAMR");
var tempDirectoryCollection = di.GetDirectories();
int pathCount = tempDirectoryCollection.Count();
var paths = new String[pathCount];
int i = 0;
for (; i < pathCount; i++)
{
var fi = tempDirectoryCollection[i];
comboBox2.Items.Add(fi.Name);
paths[i] = fi.FullName;
}
comboBox2.SelectedIndex = 0;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox2.Items.Clear();
//string dinf01 = comboBox2.SelectedItem.ToString();
DirectoryInfo dir = new DirectoryInfo(comboBox2.SelectedItem.ToString());
FileInfo[] files = dir.GetFiles("*.tif");
int i = 0;
//DirectoryInfo dir = (DirectoryInfo)comboBox2.SelectedItem;
foreach (FileInfo fi in files)
{
comboBox2.Items.Add(fi.Name);
}
foreach (FileInfo finf in files)
{
paths[i] = finf.FullName;
i++;
}
Any help and suggestions appreciated.