6
Answers

need to use some specific files from each folder of a dir.

hi, 
 
I have two directories, and every directories represent the data acquired from a software, with thesame names of folders and files name. i wanna use these files to compare with each other.  
 
What i need is a function or a method, which can get me some files based on their names, one i select the folder.
 
I used FolderBrowseDialog, to select the folder and used openfileDialog to open the files,
but instead of openfiledialog i would need another function that can automatically select particular files of that folder.
 
I had tried Directory.getfiles but can i select the files that i need based on their names(files).any filter that i can use.
 
 
Answers (6)
3
Vulpes

Vulpes

NA 98.3k 1.5m 12y
There are various ways in which you could do this but perhaps the easiest way is this - I'm assuming the first form is called Form1, its combobox is called comboBox1 and it's been placed directly on Form1, not in some container such as a panel.

The following code should be added to button1_Click on Form2:

Form1 f1 = (Form1)Application.OpenForms["Form1"];
ComboBox cb = (ComboBox)f1.Controls["comboBox1"];
cb.Items.Add(textBox1.Text);

Accepted
0
Chandrakant Patil

Chandrakant Patil

NA 110 9.5k 9y
Hi Vulpes
can u please explain also other ways because this way is not suited for my problem. I have combobox in form1 which is binding from data source and on form2 i have a text box so when i click on save button on form2  the form1 combo box not refreshed says "Items collection not modified when the datasource property is set".
0
Alireza Saffari

Alireza Saffari

NA 2 0 10y
thanks a lot :)
0
Nel

Nel

NA 713 954.7k 12y
Thank you very much Vulpes:)
0
Nel

Nel

NA 713 954.7k 12y
Thank you very much Vulpes:)
0
Nel

Nel

NA 713 954.7k 12y
Thanks, but doesn't solve the problem
0
Hi , you put u r second form button1_click code in the second form form_load event and try...