获取文件路径 [英] Getting path of a file
本文介绍了获取文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如何获取在下拉列表框中选择的文件的路径?我的代码不起作用.
Hi all,
How to get the path of a file selected in the dropdownlistbox? My code does not works.
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.
推荐答案
我的问题解决了.
使用
I got my problem solved.
use
ListBox1.Items.add(_WavFile); instead of
ListBox1.Text = _WAVFile;
这篇关于获取文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文