[英]What's the best way to allow a user to browse for a file in C#?
允许用户在C#中浏览文件的最佳方法是什么?
using (OpenFileDialog dlg = new OpenFileDialog())
{
dlg.Title = "Select a file";
if (dlg.ShowDialog()== DialogResult.OK)
{
//do something with dlg.FileName
}
}
我会说使用标准的“打开文件”对话框( OpenFileDialog ),这使得它对新用户来说不那么令人生畏,并且有助于使用一致的用户界面。
Close, Ryan, but you never showed the dialog. 关闭,Ryan,但你从未展示过对话框。 it should be:
它应该是:
if (dlg.ShowDialog() == DialogResult.OK)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.