首页 新闻 会员 周边

c#既能选择文件又能选择文件夹

0
悬赏园豆:40 [已关闭问题] 关闭于 2013-12-24 09:34

大家好,我现在想实现点击一个按钮之后弹出一个选择文件的对话框,在对话框里既能选择文件又能选择文件夹,类似于qq发送文件/文件夹的功能,但是在网上查了一些资料,大部分都是分开的

//发送文件  
private void btnFile_Click(object sender, EventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Multiselect = true;
fileDialog.Title = "请选择文件";
fileDialog.Filter="所有文件(*.*)|*.*";
if (fileDialog.ShowDialog() == DialogResult.OK)
{
string file=fileDialog.FileName;
MessageBox.Show("已选择文件:" + file,"选择文件提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
//发送文件夹
private void btnPath_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = "请选择文件路径";
if (dialog.ShowDialog() == DialogResult.OK)
{
string foldPath = dialog.SelectedPath;
MessageBox.Show("已选择文件夹:" + foldPath, "选择文件夹提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

有什么办法可以在同一个弹出窗口中实现,希望大家能给点儿思路,谢谢了!

雪~中~狼的主页 雪~中~狼 | 初学一级 | 园豆:188
提问于:2013-12-24 09:32
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册