日期:2014-05-17  浏览次数:20572 次

c#既能选择文件又能选择文件夹
大家好,我现在想实现点击一个按钮之后弹出一个选择文件的对话框,在对话框里既能选择文件又能选择文件夹,类似于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);  
            }  
        }  


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

------解决方案-------