Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,
How to get the path of a file selected in the dropdownlistbox? My code does not works.
C#
private String _WAVFile = null;
string[] files = Directory.GetFiles(@"E:\voices\", "*.wav");

        foreach (string file in files)
        {
            DropDownList1.DataSource = file;
            DropDownList1.Items.Add(new ListItem(file));
            
           
        }
// When a button is cliked
_WAVFile = Path.GetFullPath(DropDownList1.SelectedValue);
        ListBox1.Text = _WAVFile;

Thanks in advance.
Posted
Comments
Sergey Alexandrovich Kryukov 22-Feb-12 14:26pm    
"My code does not work" is not informative.
--SA
psgviscom 22-Feb-12 14:30pm    
It does not perform any action. Any error in my code?
Marcin S. Narowski 22-Feb-12 15:17pm    
could you give some example? what _WAVFile contains?

1 solution

I got my problem solved.
use
C#
ListBox1.Items.add(_WavFile); instead of 
ListBox1.Text = _WAVFile;
 
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