当前位置:网站首页>C#利用浏览按钮获得文件路径和文件夹路径
C#利用浏览按钮获得文件路径和文件夹路径
2022-07-15 15:34:00 【全栈程序员站长】
大家好,又见面了,我是全栈君
生成文件夹路径
private void btnChoose_Click(object sender, EventArgs e)
{ using (OpenFileDialog dialog = new OpenFileDialog()) { dialog.Multiselect = true; if (dialog.ShowDialog() == DialogResult.OK) { try { this.tbFilePath.Text = dialog.FileName; } catch(Exception ex) { throw(ex); } } }
生成文件路径
新建一个FolderDialog类(重载FolderNameEditor)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms.Design; using System.Windows.Forms;
namespace Common { class FolderDialog:FolderNameEditor { FolderBrowser fDialog = new FolderBrowser(); public FolderDialog(){ }
public DialogResult DisplayDialog() { return DisplayDialog(“请选择一个文件夹”); }
public DialogResult DisplayDialog(string description) { fDialog.Description = description; return fDialog.ShowDialog(); }
public string Path { get { return fDialog.DirectoryPath; } }
~FolderDialog() { fDialog.Dispose(); } } }
浏览按钮下的事件
private void btnChoose_Click(object sender, EventArgs e) { FolderDialog fDialog = new FolderDialog(); fDialog.DisplayDialog(); this.tbfilePath.Text = fDialog.Path; }
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/120496.html原文链接:https://javaforall.cn
边栏推荐
- Salesforce发布的振奋人心的新功能集锦
- 【动态规划】—— 计数类DP
- Wechat applet from getting started to learning the ninth day -- system operation of applet
- Kekeguo information management] information management paper writing requirements - unqualified papers
- C # write a GUI tool and decompile it
- The bill module of freeswitch
- Mobile Robotics (I) fundamentals of Mathematics
- 【动态规划】—— 状态压缩DP
- CFA考试报名须知
- 直播带货系统源码
猜你喜欢

送你的代码上太空,与华为云一起开发“最伟大的作品”

(pc+wap) Zhimeng template waterproof building materials website

蚂蚁隐私计算创新TEE技术获学术认可

DBeaver连接mysql错误:The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized or represents more than

Salesforce发布的振奋人心的新功能集锦
![[comprehensive pen test] difficulty 2/5, recursive application, prefix and optimization](/img/eb/fad095522129d13be7675a50e77af7.png)
[comprehensive pen test] difficulty 2/5, recursive application, prefix and optimization

Transplantation and analysis of freemodbus on stm32f1 platform

1 start.s分析

Volatile low configuration syn, realizing visibility and order

STM32F103 串口DMA + 空闲中断 实现不定长数据收发
随机推荐
Matlab_调试中figure置顶显示
The seventh day of learning C language with small Bai challenge -- Enumeration, structure, community
插值法计算两点之间的数值
Information system project managers must recite the core examination points (I) six elements of the national information system
Typora入门:全网最全教程
1 start.s分析
要想不踩SaaS那些坑,得先了解“SaaS架构”
Cjson usage
[comprehensive pen test] difficulty 2/5, recursive application, prefix and optimization
SQL实现将数据表中的字段中的值按分隔符分成多列
freeswitch的话单模块
Information system project manager core examination site (VIII) software integration technology
散户证券开户哪个券商平台好,哪个更安全
Information system project managers must recite the core examination points (IV) the relationship between UML classes
Wechat applet from getting started to learning the ninth day -- system operation of applet
rv的使用
STM32 IAP远程更新
曲线上点的曲率半径计算
Fail-Fast & Fail-Safe
cJSON使用