zoukankan      html  css  js  c++  java
  • Winform窗体程序 按钮选择文件及存储位置

    winform窗体文件中时常需要选择文件及文件存储位置

    选择文件

       System.Windows.Forms.OpenFileDialog fd = new OpenFileDialog();
                fd.Title = "选择文件";//选择框名称        
                fd.Filter = "xls files (*.xlsx)|*.xlsx";//选择文件的类型为Xls表格          
                if (fd.ShowDialog() == DialogResult.OK)//当点击确定               
                {
    
                    SelectFilePath.Text = fd.FileName.Trim();  //文件路径
                                                               //     SelectFilePath.Text = SelectFilePath.Text.Replace("\", "/");
    
                }
    选择文件

    选择多个文件:

      OpenFileDialog dlg = new OpenFileDialog();
                dlg.Multiselect = true;//等于true表示可以选择多个文件
                                       //dlg.DefaultExt = ".txt";
                                       //dlg.Filter = "记事本文件|*.txt";
                dlg.ShowDialog();
                filepath.Text = "已选择" + dlg.FileNames.Length + "个文件";
                str = dlg.FileNames;
    选择多个文件

    选择文件夹

       FolderBrowserDialog ofd = new FolderBrowserDialog();
                ofd.ShowDialog();
                DownloadPath.Text = ofd.SelectedPath.ToString();
    选择文件存储位置
  • 相关阅读:
    js5
    js4
    js(3)
    JS内容(2)
    html复习
    js介绍及内容(1)
    定位2
    position定位
    CSS
    列表及行块转变
  • 原文地址:https://www.cnblogs.com/my2020/p/14343683.html
Copyright © 2011-2022 走看看