zoukankan      html  css  js  c++  java
  • C# 可视化读取文件、文件夹


    OpenFileDialog fd = new OpenFileDialog(); fd.Filter = "txt files (*.txt)|*.txt|All files(*.*)|*.*"; fd.InitialDirectory = Application.StartupPath + "\Temp\"; fd.ShowReadOnly = true; DialogResult r = fd.ShowDialog(); if(r == DialogResult.OK) { string all = fd.FileName; string path = all.Substring(0, all.LastIndexOf("\") + 1); string fileName = all.Substring(all.LastIndexOf("\") + 1, all.LastIndexOf(".") - (all.LastIndexOf("\") + 1)); string fileExc = all.Substring(all.LastIndexOf(".") + 1, all.Length - all.LastIndexOf(".") - 1); System.Console.WriteLine("all = {0}", all); System.Console.WriteLine("path = {0}" ,path); System.Console.WriteLine("fileName = {0}", fileName); System.Console.WriteLine("fileExc = {0}",fileExc); }
    FolderBrowserDialog fbd = new FolderBrowserDialog();
                    fbd.ShowNewFolderButton = true;
    
                    if (fbd.ShowDialog() == DialogResult.OK)
                    {
                        string path = fbd.SelectedPath;
                    }
                    else
                    {
                    }
    获取该路径下的文件目录
    string[] dataFiles = Directory.GetFiles(path);
  • 相关阅读:
    vim操作
    git命令
    Python笔记(二)
    python笔记
    gdb笔记 ---《Linux.C编程一站式学习》
    python笔记——dict和set
    echo $?
    FastDFS与Nginx环境配置
    Nginx依赖库安装
    mixin多继承包装过程
  • 原文地址:https://www.cnblogs.com/ficow/p/5428264.html
Copyright © 2011-2022 走看看