42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace ZXLT.FileSystem
|
|
{
|
|
public sealed class DirectoryInfo : FileSystemInfo
|
|
{
|
|
// List<DirectoryInfo> directories = new List<DirectoryInfo>();
|
|
// List<FileInfo> files = new List<FileInfo>();
|
|
|
|
public override bool Exists { get; }
|
|
public override string Name => _name;
|
|
public override FileSystemInfoType FileSystemInfoType { get; }
|
|
|
|
public DirectoryInfo Parent
|
|
{
|
|
get
|
|
{
|
|
var parentPath = FullPath.Split("\\")[^1];
|
|
var directoryInfo = new DirectoryInfo(System.IO.Path.GetFullPath(parentPath));
|
|
return directoryInfo;
|
|
}
|
|
}
|
|
|
|
public DirectoryInfo Root => new DirectoryInfo(System.IO.Path.GetPathRoot(this.FullPath));
|
|
|
|
public DirectoryInfo(string path)
|
|
{
|
|
FullPath = System.IO.Path.GetFullPath(path);
|
|
_name = System.IO.Path.GetDirectoryName(path);
|
|
}
|
|
|
|
// public DirectoryInfo[] GetDirectories()
|
|
// {
|
|
// return directories.ToArray();
|
|
// }
|
|
//
|
|
// public FileInfo[] GetFiles()
|
|
// {
|
|
// return files.ToArray();
|
|
// }
|
|
}
|
|
} |