31 lines
965 B
C#
31 lines
965 B
C#
using System;
|
|
using System.IO;
|
|
|
|
namespace ZXLT.FileSystem
|
|
{
|
|
public sealed class FileInfo : FileSystemInfo
|
|
{
|
|
public string Extension => Path.GetExtension(this.FullName);
|
|
public override bool Exists { get; }
|
|
public override string Name => _name;
|
|
public override FileSystemInfoType FileSystemInfoType { get; }
|
|
public string? DirectoryName => Path.GetDirectoryName(this.FullPath);
|
|
|
|
public DirectoryInfo Directory
|
|
{
|
|
get
|
|
{
|
|
string directoryName = this.DirectoryName;
|
|
return new DirectoryInfo(directoryName);
|
|
}
|
|
}
|
|
|
|
public FileInfo(string fileName)
|
|
{
|
|
fileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
|
|
_name = Path.GetFileName(fileName);
|
|
this.FullPath = Path.GetFullPath(fileName);
|
|
FileSystemInfoType = FileSystemInfoType.File;
|
|
}
|
|
}
|
|
} |