Struct FilePath
Represents a file path wrapper that provides lightweight, non-I/O path manipulation helpers.
public readonly record struct FilePath : IFileSystemPath, IEquatable<FilePath>
- Implements
- Inherited Members
- Extension Methods
Constructors
FilePath(FileInfo)
public FilePath(FileInfo fileInfo)
Parameters
FilePath(string)
Represents a file path wrapper that provides lightweight, non-I/O path manipulation helpers.
public FilePath(string Path)
Parameters
PathstringThe file path. This type does not validate existence or interact with the file system; it only stores and manipulates the path string.
Properties
Directory
Gets the directory portion of this file path.
public DirectoryPath Directory { get; }
Property Value
Extension
Gets the extension portion of this file path, including the leading dot when present.
public string Extension { get; }
Property Value
ExtensionlessFileName
Gets the file name portion of this file path without an extension.
public string ExtensionlessFileName { get; }
Property Value
FileInfo
Gets a FileInfo wrapper for this path.
public FileInfo FileInfo { get; }
Property Value
Remarks
Creating a FileInfo does not access the file system. Accessing certain members of the returned instance may.
FileName
Gets the file name portion of this file path.
public string FileName { get; }
Property Value
Path
The file path. This type does not validate existence or interact with the file system; it only stores and manipulates the path string.
public string Path { get; init; }
Property Value
Methods
WithExtension(string)
Returns a new FilePath with its extension changed.
public FilePath WithExtension(string newExtension)
Parameters
newExtensionstringThe new extension to apply. The leading dot is optional.
Returns
WithFileName(string)
Returns a new FilePath with its file name changed, preserving the directory portion of this path.
public FilePath WithFileName(string newFileName)
Parameters
newFileNamestringThe new file name to use.
Returns
Operators
implicit operator FilePath(FileInfo)
public static implicit operator FilePath(FileInfo path)
Parameters
pathFileInfo
Returns
implicit operator FilePath(string)
Converts a path string to a FilePath instance.
public static implicit operator FilePath(string path)
Parameters
pathstring