服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-04-12 646ce5990fb03908a0371fc4ca8416905b27a4d1
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Tiger.IBusiness;
 
namespace Tiger.IBusiness
{
    public class UpgradeFileSystem
    {
        public UpgradeFileSystem()
        {
        }
        public UpgradeFileSystem(FileInfo fi)
        {
            Name = fi.Name;
            FullName = fi.FullName.Replace(UpgradeRootPath, "");
            Path = fi.DirectoryName.Replace(UpgradeRootPath, "");
            Extension = fi.Extension;
            IsDirectory = false;
            LastWriteTime = fi.LastWriteTime;
            Length = fi.Length;
        }
        public UpgradeFileSystem(DirectoryInfo di)
        {
            Name = di.Name;
            FullName = di.FullName.Replace(UpgradeRootPath, "");
            Path = di.FullName.Replace(UpgradeRootPath, "");
            Extension = di.Extension;
            IsDirectory = true;
            LastWriteTime = di.LastWriteTime;
            Length = 0;
            ChildNodes = GetAllFiles(di);
        }
        /// <summary>
        /// 程序更新根目录
        /// </summary>
        public static string UpgradeRootPath => ApiConfig.UpgradePath;
        public string Name { set; get; }
        public string Path { set; get; }
        public string FullName { set; get; }
        public long Length { set; get; }
        public string Extension { set; get; }
        public DateTime LastWriteTime { set; get; }
        public bool IsDirectory { set; get; }
        public List<UpgradeFileSystem> ChildNodes { set; get; } = new List<UpgradeFileSystem>();
 
        private List<UpgradeFileSystem> GetAllFiles(DirectoryInfo di)
        {
            var allFiles = new List<UpgradeFileSystem>();
 
            foreach (var item in di.GetDirectories())
            {
                allFiles.Add(new UpgradeFileSystem(new DirectoryInfo(item.FullName)));
            }
 
            foreach (var item in di.GetFiles())
            {
                allFiles.Add(new UpgradeFileSystem(new FileInfo(item.FullName)));
            }
 
            return allFiles;
        }
 
    }//endCLass
}