ComboBox Visual Studio Csharp

1

I'm completing a system with two combobox

In comboBox1 you should see the folder name for the user selection, In comboBox2 you should see the .exe that will be transferred to a directory after clicking a button to copy the selected file to combobox .

I looked at some tutorials on the internet, but found none in this way.

Does anyone have any tips ??

    
asked by anonymous 24.03.2018 / 07:50

1 answer

1

How to use combobox:

private void FillCombo()
{
    var dirs = Directory.GetDirectories(@"C:\temp");
    var files = Directory.GetFiles(@"C:\test2", "*.exe");

    foreach (var t in dirs)
    {
        cmbDir.Items.Add(t);
    }

    foreach (var t in files)
    {
        cmbArq.Items.Add(t);
    }
}

To copy the files:

File.Copy("arquivoOrigem", "arquivoDestino");

Do not forget to using System.IO;

Now if you want to select more than one file you can use the checkedListBox or ListView. The procedure is the same.

    
24.03.2018 / 08:32