Form1.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

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

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

        private void Form1_Load(object sender, EventArgs e)
        {
            /*
             第一种方法
             *             //获取exe文件的完整路劲
            string exxpath = Assembly.GetExecutingAssembly().Location;
            //获取demo文件夹的完整路劲
            string path = Path.Combine(Path.GetDirectoryName(exxpath), "demo"); 

             */



            //窗口加载事件
            //1、获取路劲
            string path = "C:\\Users\\jiuqing\\Desktop";

            //2、调用方法递归加载
            loadata(path, treeView1.Nodes);
        }

        private void loadata(string path, TreeNodeCollection treeNodeCollection)
        {
            //1、获取path下的所有的目录与文件
            string[] files = Directory.GetFiles(path,"*.txt");
            string[] dirs = Directory.GetDirectories(path);

            //遍历加载到treeview上
            //文件
            foreach (string item in files)
            {
               TreeNode node= treeNodeCollection.Add(Path.GetFileName(item));
                //如果是文件节点,则把当前节点的完整路劲保存在节点的tag属性中
               node.Tag = item;
            }
            //目录
            foreach (string  item in dirs)
            {
              TreeNode node=treeNodeCollection.Add(Path.GetFileName(item));
后面还有 24 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。