Admin
2025-12-02 9e42f0dafa019f5ecf6b0ff425ecb966b002171e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
 
namespace WIDESEA_Services.Services.Log
{
    public class LogService
    {
 
        public ArrayList al = new ArrayList();
        //我把ArrayList当成动态数组用,非常好用
        public ArrayList GetAllDirList(string strBaseDir)
        {
            DirectoryInfo di = new DirectoryInfo(strBaseDir);
            DirectoryInfo[] diA = di.GetDirectories();
            for (int i = 0; i < diA.Length; i++)
 
            {
                al.Add(diA[i].FullName);
                GetAllDirList(diA[i].FullName);
            }
 
            return al;
        }
 
 
 
        //获得指定路径下所有文件名
        public static List<FileNames> getFileName(List<FileNames> list, string filepath)
        {
            DirectoryInfo root = new DirectoryInfo(filepath);
            foreach (FileInfo f in root.GetFiles())
            {
                list.Add(new FileNames
                {
                    label = f.FullName, //f.Name,
                    path = f.FullName,
                });
            }
            return list;
        }
        //获得指定路径下的所有子目录名
        // <param name="list">文件列表</param>
        // <param name="path">文件夹路径</param>
        public static List<FileNames> GetallDirectory(List<FileNames> list, string path)
        {
            DirectoryInfo root = new DirectoryInfo(path);
            var dirs = root.GetDirectories();
            if (dirs.Count() != 0)
            {
                foreach (DirectoryInfo d in dirs)
                {
                    list.Add(new FileNames
                    {
                        label = d.Name,
                        path = d.FullName,
                        children = GetallDirectory(new List<FileNames>(), d.FullName)
                    }); ;
                }
            }
            list = getFileName(list, path);
            return list;
        }
 
    }
 
 
    public class FileNames
    {
        //public int id { get; set; }
        //public string text { get; set; }
        //public state state { get; set; }
        //public List<FileNames> children { get; set; }
        //public string icon { get; set; }
 
        public string label { get; set; }
        public List<FileNames> children { get; set; }
        public string path { get; set; }
    }
    public class state
    {
        public bool opened { get; set; }
    }
}