------ #### SuperDesign V3.0.2412.2001 - *.[新增]新增程序更新日志设置和自动发布功能。 - *.[修复]修复Post数据格式不正确时双击文本框会导致软件闪退的BUG。
92 lines
2.9 KiB
C#
92 lines
2.9 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlTypes;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Linq;
|
|
using static System.Net.WebRequestMethods;
|
|
|
|
namespace SuperDesign.Tools.SmartEditor
|
|
{
|
|
public class MyFileSystemInfo
|
|
{
|
|
public MyFileSystemInfo(FileSystemInfo fileSystemInfo,string name)
|
|
{
|
|
if (fileSystemInfo == null) throw new ArgumentNullException("fileSystemInfo");
|
|
ReLoad(fileSystemInfo,name);
|
|
}
|
|
public void ReLoad()
|
|
{
|
|
ReLoad(FullName);
|
|
}
|
|
public void ReLoad(string path)
|
|
{
|
|
if(System.IO.File.Exists(path))
|
|
{
|
|
ReLoad(new FileInfo(path), "");
|
|
}
|
|
else if (System.IO.Directory.Exists(path))
|
|
{
|
|
ReLoad(new DirectoryInfo(path), "");
|
|
}
|
|
}
|
|
public void ReLoad(FileSystemInfo fileSystemInfo)
|
|
{
|
|
ReLoad(fileSystemInfo, "");
|
|
}
|
|
public void ReLoad(FileSystemInfo fileSystemInfo, string name)
|
|
{
|
|
var info = fileSystemInfo;
|
|
if (name.Length == 0)
|
|
{
|
|
this.Name = info.Name;
|
|
}
|
|
else { this.Name = name; }
|
|
Extension = info.Extension;
|
|
LastWriteTime = info.LastWriteTime;
|
|
CreationTime = info.CreationTime;
|
|
FullName = info.FullName;
|
|
Attributes = info.Attributes;
|
|
AsDirectory = info as DirectoryInfo;
|
|
AsFile = info as FileInfo;
|
|
IsDirectory = this.AsDirectory != null;
|
|
Length = IsDirectory ? -1 : AsFile.Length;
|
|
}
|
|
public bool IsDirectory { get;private set; }
|
|
|
|
public DirectoryInfo AsDirectory { get; private set; }
|
|
public FileInfo AsFile { get; private set; }
|
|
|
|
public string Name{get; set;} = "";
|
|
|
|
public string Extension { get; private set; } = "";
|
|
public DateTime LastWriteTime { get; private set; }
|
|
public DateTime CreationTime { get; private set; }
|
|
public string FullName { get; private set; } = "";
|
|
|
|
public FileAttributes Attributes { get;private set; }
|
|
|
|
public long Length { get; private set; } = 0;
|
|
|
|
public IEnumerable GetFileSystemInfos()
|
|
{
|
|
ArrayList children = new ArrayList();
|
|
if (this.IsDirectory)
|
|
{
|
|
if (this.AsDirectory.Exists) {
|
|
foreach (var x in this.AsDirectory.GetDirectories()) {
|
|
children.Add(new MyFileSystemInfo(x, ""));
|
|
}
|
|
foreach (var x in this.AsDirectory.GetFiles()) {
|
|
children.Add(new MyFileSystemInfo(x, ""));
|
|
}
|
|
}
|
|
}
|
|
return children;
|
|
}
|
|
}
|
|
}
|