• 大小: 223KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: 其他
  • 标签: 源码  winform  

资源简介

可看见系统隐藏文件,类似windows系统的资源管理器,并附带多种功能,代码可修改以适用于多种场合

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;





namespace Explorers
{
    public partial class Form1 : Form
    {
        public bool set = false;
        string namePath;
        string name;
        public int indexs;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
           
        }
        
        public void tvExplore_AfterSelect(object senderTreeViewEventArgs e) 
        {
            TreeNode node = this.tvNode.SelectedNode;
            InitialNode(node);
        }
        public void InitialNode(TreeNode node)
        {
            try
            {
               
                DirectoryInfo direct = new DirectoryInfo(node.Tag.ToString());

                DirectoryInfo[] directs = direct.GetDirectories();
                foreach (DirectoryInfo di in directs)
                {
                    TreeNode nod = new TreeNode();
                    nod.Text = di.Name;
                    nod.Tag = di.FullName;
                    node.Nodes.Add(nod);
                }
                InitialDgv(direct);
            }catch(Exception ex)
            {
                if (set)
                {
                    if(!ex.Message.Equals(“未将对象引用设置到对象的实例。“)){
                    MessageBox.Show(ex.Message);}
                   
                }
                set = true;
            }
        }
        public void InitialDgv(DirectoryInfo direct) 
        {
            FileInfo [] infos =direct.GetFiles();
            List files = new List();
            foreach(FileInfo info in infos)
            {
                MyFile file = new MyFile();
                file.FileName = info.Name;
                file.FileLength = info.Length;
                file.FileType = info.Extension;
                file.FilePath = info.FullName;
                files.Add(file);
            }
            this.dgvSelect.DataSource =new BindingList(files);
            SetName_Click(null null); 
        }
        private void SetName_Click(object sender EventArgs e) 
        {
            if(this.dgvSelect.CurrentRow.Index!=indexs){
            this.namePath = this.dgvSelect.CurrentRow.Cells[“FilePath“].Value.ToString();
            this.name = this.dgvSelect.CurrentRow.Cells[“FileName“].Value.ToString();
            this.indexs = this.dgvSelect.CurrentRow.Index;
                }
        }

        private void tsmiSetName_Click(object sender EventArgs e)
        {
           
         
          
            string names = this.dgvSelect.CurrentRow.Cells[“FileName“].Value.ToString();

            string paths = namePath.Substring(0 namePath.Length - name.Length);
               strin

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-29 17:21  Explorers\
     目录           0  2018-06-29 17:21  Explorers\.vs\
     目录           0  2018-06-29 17:21  Explorers\.vs\Explorers\
     目录           0  2018-06-29 17:21  Explorers\.vs\Explorers\DesignTimeBuild\
     文件         134  2018-06-29 17:21  Explorers\.vs\Explorers\DesignTimeBuild\.dtbcache
     目录           0  2018-06-29 17:21  Explorers\.vs\Explorers\v15\
     文件       45568  2018-08-25 12:57  Explorers\.vs\Explorers\v15\.suo
     目录           0  2018-06-29 17:21  Explorers\.vs\Explorers\v15\Server\
     目录           0  2018-06-29 17:21  Explorers\.vs\Explorers\v15\Server\sqlite3\
     文件           0  2018-06-29 17:21  Explorers\.vs\Explorers\v15\Server\sqlite3\db.lock
     文件        4096  2018-06-29 17:21  Explorers\.vs\Explorers\v15\Server\sqlite3\storage.ide
     文件       32768  2018-08-25 12:52  Explorers\.vs\Explorers\v15\Server\sqlite3\storage.ide-shm
     文件      655112  2018-06-29 17:21  Explorers\.vs\Explorers\v15\Server\sqlite3\storage.ide-wal
     目录           0  2018-06-17 19:17  Explorers\Explorers\
     文件         869  2018-06-01 11:59  Explorers\Explorers.sln
     文件       22528  2018-06-01 11:59  Explorers\Explorers.suo
     目录           0  2018-06-17 19:17  Explorers\Explorers\bin\
     目录           0  2018-09-05 13:18  Explorers\Explorers\bin\Debug\
     文件         222  2018-06-01 11:59  Explorers\Explorers\bin\Debug\Configdwa.ini
     文件       14336  2018-08-25 12:51  Explorers\Explorers\bin\Debug\Explorers.exe
     文件       28160  2018-08-25 12:51  Explorers\Explorers\bin\Debug\Explorers.pdb
     文件       11600  2018-06-01 11:59  Explorers\Explorers\bin\Debug\Explorers.vshost.exe
     文件         490  2018-06-01 11:59  Explorers\Explorers\bin\Debug\Explorers.vshost.exe.manifest
     文件        3714  2018-06-01 11:59  Explorers\Explorers\Explorers.csproj
     文件        4379  2018-06-01 11:59  Explorers\Explorers\Form1.cs
     文件        9142  2018-06-01 11:59  Explorers\Explorers\Form1.Designer.cs
     文件        6760  2018-06-01 11:59  Explorers\Explorers\Form1.resx
     文件         339  2018-06-01 11:59  Explorers\Explorers\MyFile.cs
     目录           0  2018-06-17 19:17  Explorers\Explorers\obj\
     目录           0  2018-06-17 19:17  Explorers\Explorers\obj\x86\
     目录           0  2018-08-25 12:51  Explorers\Explorers\obj\x86\Debug\
............此处省略19个文件信息

评论

共有 条评论