C# winform 选择文件保存路径

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());
                }
            }
        }

原文地址:https://www.cnblogs.com/youmingkuang/p/9723673.html

时间: 2024-08-29 13:18:49

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

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

private void btnFile_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; fileDialog.Title = "请选择文件"; fileDialog.Filter="所有文件(*.*)|*.*"; if (fileDialog.ShowDialog() == Dia

选择文件保存路径

<input id="Button1" type="button" value="选择路径" onclick="javascript:browseFolder()"/><input id="show" type="text" /> <script> function browseFolder() { try { var Message = "

C# WinForm 选择目录路径和文件路径

private string SelectPath() //弹出一个选择目录的对话框 { FolderBrowserDialog path = new FolderBrowserDialog(); path.ShowDialog(); return path.SelectedPath; } private string SelectFile() //弹出一个选择文件的对话框 { OpenFileDialog file = new OpenFileDialog(); file.ShowDialog

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

C# winform文件批量转编码 选择文件夹 打开指定目录 private void btnFile_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; fileDialog.Title = "请选择文件"; fileDialog.Filter="所有文件(*.*)|*.*"; if

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

https://blog.csdn.net/zaocha321/article/details/52528279 using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public par

多选择文件打开对话框

多选择文件打开对话框 关键点 可以打开多个文件 实现过程 CString filter = "文本文档(*.txt)|*.txt|所有文件(*.*)|*.*||"; CFileDialog OpenFileDialog(TRUE, NULL, "*.txt", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT, filter); //     OpenFileDialog.m_ofn.lpstrI

修改JFileChooser对话框风格,设置打开对话框的默认文件名,获取改变路径之后的文件保存路径

Javascript是一种基于对象(object-based)的语言,你遇到的所有东西几乎都是对象.但是,它又不是一种真正的面向对象编程(OOP)语言,因为它的语法中没有class(类). 那么,如果我们要把"属性"(property)和"方法"(method),封装成一个对象,甚至要从原型对象生成一个实例对象,我们应该怎么做呢? 一. 生成对象的原始模式 假定我们把猫看成一个对象,它有"名字"和"颜色"两个属性. var C

选择文件夹,路径选择

选择文件夹,路径选择, SelectDirectory #include "FileCtrl.hpp" const SELDIRHELP = 1000; void __fastcall TForm1::Button1Click(TObject *Sender) { String Dir = "C:\\Program Files\\CodeGear"; if (SelectDirectory(Dir, TSelectDirOpts() << sdAllow

C# 选择文件夹 选择文件

选择文件 1 //选择文件 2 OpenFileDialog dialog = new OpenFileDialog(); 3 dialog.Multiselect = true;//该值确定是否可以选择多个文件 4 dialog.Title = "请选择文件夹"; 5 dialog.Filter = "所有文件(*.*)|*.*"; 6 if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)