EditorTool3D/Assets/ZXL/Scripts/FileSystem/FileInfo.cs

31 lines
965 B
C#
Raw Normal View History

2024-12-18 23:46:42 +08:00
using System;
using System.IO;
namespace ZXLT.FileSystem
{
public sealed class FileInfo : FileSystemInfo
{
2024-12-19 23:07:52 +08:00
public string Extension => Path.GetExtension(this.FullName);
2024-12-18 23:46:42 +08:00
public override bool Exists { get; }
public override string Name => _name;
2024-12-19 23:07:52 +08:00
public override FileSystemInfoType FileSystemInfoType { get; }
2024-12-18 23:46:42 +08:00
public string? DirectoryName => Path.GetDirectoryName(this.FullPath);
public DirectoryInfo Directory
{
get
{
string directoryName = this.DirectoryName;
return new DirectoryInfo(directoryName);
}
}
public FileInfo(string fileName)
{
2024-12-19 23:07:52 +08:00
fileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
_name = Path.GetFileName(fileName);
this.FullPath = Path.GetFullPath(fileName);
FileSystemInfoType = FileSystemInfoType.File;
2024-12-18 23:46:42 +08:00
}
}
}