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
|
}
|