使用C#选择文件夹、打开文件夹、选择文件
2024-08-24 02:02:05
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms; namespace TestFolderBrowserDialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} 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);
}
} private void btnOpen_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("Explorer.exe","c:\\windows");
}
}
}
最新文章
- TransmitFile函数的简单使用
- MCV之行为
- 响应性web设计实战总结
- Mac OS X 中使用SAP GUI的方法
- HTML5 WebAudioAPI-实例(二)
- C++引用形参,函数返回多个值
- k8s集群监控(十一)--技术流ken
- 简单的shell命令
- openflow流表分析(草稿)
- Mybatis的bind动态SQL
- (简单)华为M3揽月 BTV-W09的Usb调试模式在哪里开启的经验
- MySQL的视图总结
- Linux系统下yum镜像源环境部署记录
- 拖放排序插件Sortable.js 兼容好及功能全个人觉得比dragula.js 好的多
- cookie 简单用法
- SEO优化之“不要轻易使用泛解析”
- 23.Xcode中常用的快捷键操作
- 事件委托,js中的一种优化方法
- 数据库索引&;数据页
- SCARA——OpenGL入门学习三
热门文章
- PowerDesigner16.5 生成SQL脚本执行出错:collate chinese_prc_ci_as
- javascript笔记——date以及datetime的比较
- css笔记——inline-block以及空白字符处理
- makefile--编译出现,未定义的字符
- [ZZ+CH] Html5 canvas+js 时钟
- Mysql 作业(Scheduler)
- ajax返回的json内容进行排序
- [WinForm]为TextBox设置水印文字
- [译]Java Thread wait, notify和notifyAll示例
- dapper.rainbow