1、winform 点击按钮选择文件保存的路径,效果如下图:

具体代码如下:

     private void button8_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = "请选择文件路径"; if (dialog.ShowDialog() == DialogResult.OK)
{
string foldPath = dialog.SelectedPath;
DirectoryInfo theFolder = new DirectoryInfo(foldPath); //theFolder 包含文件路径 FileInfo[] dirInfo = theFolder.GetFiles();
//遍历文件夹
foreach (FileInfo file in dirInfo)
{
MessageBox.Show(file.ToString());
}
}
}

winform 打开指定的文件夹

 System.Diagnostics.Process.Start("路径");

2、winform 打开指定文件,精确到文件

OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = true;//该值确定是否可以选择多个文件
dialog.Title = "请选择文件夹";
dialog.Filter = "所有文件(*.*)|*.*";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string file = dialog.FileName;
}

C# winform 选择文件保存路径的更多相关文章

  1. c#winform选择文件,文件夹,打开指定目录方法

    private void btnFile_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDia ...

  2. C# winform选择文件、选择文件夹、打开文件

    文章来自博客园友,这里只是做一下笔记. 来源:https://www.cnblogs.com/liuqifeng/p/9149125.html 一.选择文件用OpenDialog OpenFileDi ...

  3. C# WINFORM 编程中,选择**文件夹**而不是文件的方法(转)

    我们选择文件可以用 OpenFileDialog ,但是文件夹有两种方法. 法一: 用C#的FolderNameEditor类的子类FolderBrowser类来实现获取浏览文件夹对话框的功能.下面来 ...

  4. C# winform中 选择文件和保存文件

    转载自https://blog.csdn.net/qq_31788297/article/details/62047952 我们在使用桌面软件的时候经常会使用到选择文件并打开和另存为等的窗口,这样方便 ...

  5. C# winform文件批量转编码 选择文件夹

    C# winform文件批量转编码 选择文件夹 打开指定目录 private void btnFile_Click(object sender, EventArgs e) { OpenFileDial ...

  6. winform中选择文件获取路径

    private void button1_Click(object sender, EventArgs e) { //此时弹出一个可以选择文件的窗体 OpenFileDialog fileDialog ...

  7. Winform选择目录路径与选择文件路径

    https://blog.csdn.net/zaocha321/article/details/52528279 using System.Collections.Generic; using Sys ...

  8. winform 保存文件 打开文件 选择文件 字体样式颜色(流 using System.IO;)

    string filePath = ""; private void 保存SToolStripMenuItem_Click(object sender, EventArgs e) ...

  9. winform 实现选择文件和选择文件夹对话框

    //选择文件,点击[浏览],选择文件 private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileD ...

随机推荐

  1. mysql批量插入

    有多种方式 其中效率高 要求低的方式 是 把sql拼接出来 后一次性commit: eg: public int insertBatch(List<PeccDetailModel> lis ...

  2. xss脚本绕过限制的方法

    第一关:第一关比较简单,直接写入标签就可以,这里不多说了,payload如下: http://sqler.win/xss/level1.php?name=test%3Csvg/onload=alert ...

  3. SQL[Err]ORA-00932: inconsistent datatypes: expected NUMBER got CHAR:

    ORA-00932: inconsistent datatypes: expected NUMBER got CHAR: 获取的目标类型与源类型不一致,多出现在case when 语句中,when的结 ...

  4. Python静态方法(staticmethod)和类方法(classmthod)

    Python静态方法(staticmethod)和类方法(classmthod)翻了翻之前的笔记,也刚好看到一篇不错的blog,关于静态方法和类方法的,方便以后查阅,就写在这里了,废话不多说,直接上代 ...

  5. CookieUitl

    import javax.servlet.http.Cookie;import javax.servlet.http.HttpServletRequest;import javax.servlet.h ...

  6. oracle数据库导出与导入

    一.查询导出库的字符集 3个 1.查询oracle server端的字符集 SQL>select userenv('language') from dual; USERENV('LANGUAGE ...

  7. Oracle数据库分组排序

    select row_number() over(partition by oea03 order by oea02 desc) num,oea01,oea02,oea03 from oea_file ...

  8. 2018-2019-1 20189203《Linux内核原理与分析》第八周作业

    第一部分 课本学习 ELF文件(目标文件)格式主要三种: 1)可重定向文件:文件保存着代码和适当的数据,用来和其他的目标文件一起来创建一个可执行文件或者是一个共享目标文件.(目标文件或者静态库文件,即 ...

  9. python_MySQL

    原文章连接:http://www.runoob.com/python/python-mysql.html 配置数据库 conn = mysql.connector.connect(user='root ...

  10. windows程序设计 基础

    API全名(Application Program Interface) Windows窗口主函数 int WINAPI WinMain( HINSTANCE hInstance,//应用程序本次运行 ...