• 大小: 57KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-11
  • 语言: 其他
  • 标签: C#  windows  listview  

资源简介

实现类似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;
using System.Diagnostics;

namespace ResourceManager
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            AddDriver();
        }
        /// 
        /// 添加驱动器
        /// 

        private void AddDriver()
        {
            treeView1.BeginUpdate();
            treeView1.Nodes.Clear();

            DriveInfo[] Drives = DriveInfo.GetDrives();
            foreach (DriveInfo  drive in Drives )
            {
                TreeNode node = new TreeNode(drive.Name00);
                treeView1.Nodes.Add(node);
                AddChildre(node);
            }

            treeView1.EndUpdate();
        }
        /// 
        /// 添加子节点
        /// 

        /// 父节点
        private void AddChildre(TreeNode node)
        {
           DirectoryInfo[] dirs;
            try
            {
             dirs = new DirectoryInfo(node .FullPath).GetDirectories();
            }
            catch
            {
                return;
            }
            node.Nodes.Clear();
            foreach (DirectoryInfo di in dirs)
            {
                TreeNode node1 = new TreeNode(di.Name12);
                node.Nodes.Add(node1);
            }
        }

        /// 
        /// 展开节点前执行
        /// 

        /// 
        /// 
        private void treeView1_BeforeExpand(object sender TreeViewCancelEventArgs e)
        {
            treeView1.BeginUpdate();
            TreeNode node = e.Node;
            foreach (TreeNode  node1 in node.Nodes  )
            {
                
                AddChildre(node1);
            }
            treeView1.EndUpdate();
        }
        /// 
        /// 选择该节点后,将文件夹内的文件显示出来
        /// 

        /// 
        /// 
        private void treeView1_AfterSelect(object sender TreeViewEventArgs e)
        {
            TreeNode node = e.Node;
            FileInfo[] f;
            e.Node.Expand();
            listView1.Items.Clear();
            try 
        {      
               DirectoryInfo dir=new DirectoryInfo (node .FullPath );
               f = dir.GetFiles();
        }
       catch (Exception)
        {
                return;
        }
            foreach (FileInfo  f1 in f)
            {
                ListViewItem lv = new ListViewItem(f1.Name ); 
                lv.ImageIndex = 3;
                lv.ToolTipText = “双击打开文件“;
                lv.SubItems.A

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      18432  2010-10-23 11:03  ResourceManager\ResourceManager\bin\Debug\ResourceManager.exe

     文件      30208  2010-10-23 11:03  ResourceManager\ResourceManager\bin\Debug\ResourceManager.pdb

     文件      11600  2010-10-23 13:19  ResourceManager\ResourceManager\bin\Debug\ResourceManager.vshost.exe

     文件        490  2010-03-17 22:39  ResourceManager\ResourceManager\bin\Debug\ResourceManager.vshost.exe.manifest

     文件       4752  2010-10-23 10:02  ResourceManager\ResourceManager\Form1.cs

     文件      11985  2010-10-22 20:15  ResourceManager\ResourceManager\Form1.Designer.cs

     文件      11384  2010-10-22 20:15  ResourceManager\ResourceManager\Form1.resx

     文件       4440  2010-10-22 08:47  ResourceManager\ResourceManager\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6247  2010-10-23 11:03  ResourceManager\ResourceManager\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        252  2010-10-22 20:15  ResourceManager\ResourceManager\obj\x86\Debug\GenerateResource.read.1.tlog

     文件        634  2010-10-22 20:15  ResourceManager\ResourceManager\obj\x86\Debug\GenerateResource.write.1.tlog

     文件       7897  2010-10-22 08:50  ResourceManager\ResourceManager\obj\x86\Debug\ResolveAssemblyReference.cache

     文件        826  2010-10-23 13:19  ResourceManager\ResourceManager\obj\x86\Debug\ResourceManager.csproj.FileListAbsolute.txt

     文件      18432  2010-10-23 11:03  ResourceManager\ResourceManager\obj\x86\Debug\ResourceManager.exe

     文件       3585  2010-10-22 20:15  ResourceManager\ResourceManager\obj\x86\Debug\ResourceManager.Form1.resources

     文件      30208  2010-10-23 11:03  ResourceManager\ResourceManager\obj\x86\Debug\ResourceManager.pdb

     文件        180  2010-10-21 20:02  ResourceManager\ResourceManager\obj\x86\Debug\ResourceManager.Properties.Resources.resources

     文件        496  2010-10-21 20:00  ResourceManager\ResourceManager\Program.cs

     文件       1362  2010-10-21 20:00  ResourceManager\ResourceManager\Properties\AssemblyInfo.cs

     文件       2878  2010-10-21 20:00  ResourceManager\ResourceManager\Properties\Resources.Designer.cs

     文件       5612  2010-10-21 20:00  ResourceManager\ResourceManager\Properties\Resources.resx

     文件       1098  2010-10-21 20:00  ResourceManager\ResourceManager\Properties\Settings.Designer.cs

     文件        249  2010-10-21 20:00  ResourceManager\ResourceManager\Properties\Settings.settings

     文件       3689  2010-10-21 20:02  ResourceManager\ResourceManager\ResourceManager.csproj

     文件        887  2010-10-21 20:00  ResourceManager\ResourceManager.sln

     文件      19968  2010-10-23 13:20  ResourceManager\ResourceManager.suo

     目录          0  2010-10-21 20:00  ResourceManager\ResourceManager\obj\x86\Debug\TempPE

     目录          0  2010-10-23 11:03  ResourceManager\ResourceManager\obj\x86\Debug

     目录          0  2010-10-21 20:02  ResourceManager\ResourceManager\bin\Debug

     目录          0  2010-10-21 20:00  ResourceManager\ResourceManager\obj\x86

............此处省略8个文件信息

评论

共有 条评论