Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a comboBox which contains:
file1
file2
file3

i want to upload file1 (which is existed already) by select file1 from comboBox
how can i do this?
Posted
Comments
joshrduncan2012 17-Sep-13 14:56pm    
What have you tried so far to accomplish this? Do you want someone to provide a ready-made solution for you?
BillWoodruff 17-Sep-13 20:31pm    
what exactly do you mean by "upload" here: to read the file into a string ? to read the file into ... ?
Member 10220821 18-Sep-13 7:59am    
yes, to read it into string
BillWoodruff 18-Sep-13 8:56am    
Then, if Mejed's answer works for you, accept it, and vote it up.

1 solution

Hi
Here is the code
C#
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    string path=comboBox1.SelectedItem.ToString()+".txt";
    string[] myfile;
    if (System.IO.File.Exists(path))
    {
        myfile=System.IO.File.ReadAllLines(path);
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900