日期:2014-05-20  浏览次数:21073 次

silverlight 里如何限制 打开的文件类型呀?
比如上传文件
 打开对话框时,如何限制,只能选择TXT文件呀?

 谢谢

------解决方案--------------------
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Text Files (*.txt)|*.txt";
if (dlg.ShowDialog() == DialogResult.OK)
{
using (StreamReader reader = dlg.SelectedFile.OpenText())

string text = reader.ReadToEnd();
}
}