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);
}
///
/// 程序更新根目录
///
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 ChildNodes { set; get; } = new List();
private List GetAllFiles(DirectoryInfo di)
{
var allFiles = new List();
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
}