Table of Contents

Struct FilePath

Namespace
Garyon.Objects.IO
Assembly
Garyon.dll

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)

Initializes a new instance of FilePath from a FileInfo instance.

public FilePath(FileInfo fileInfo)

Parameters

fileInfo FileInfo

The FileInfo whose FullName will be stored.

FilePath(string)

Represents a file path wrapper that provides lightweight, non-I/O path manipulation helpers.

public FilePath(string Path)

Parameters

Path string

The 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

DirectoryPath

Extension

Gets the extension portion of this file path, including the leading dot when present.

public string Extension { get; }

Property Value

string

ExtensionlessFileName

Gets the file name portion of this file path without an extension.

public string ExtensionlessFileName { get; }

Property Value

string

FileInfo

Gets a FileInfo wrapper for this path.

public FileInfo FileInfo { get; }

Property Value

FileInfo

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

string

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

string

Methods

WithExtension(string)

Returns a new FilePath with its extension changed.

public FilePath WithExtension(string newExtension)

Parameters

newExtension string

The new extension to apply. The leading dot is optional.

Returns

FilePath

WithFileName(string)

Returns a new FilePath with its file name changed, preserving the directory portion of this path.

public FilePath WithFileName(string newFileName)

Parameters

newFileName string

The new file name to use.

Returns

FilePath

Operators

implicit operator FilePath(FileInfo)

Converts a FileInfo instance to a FilePath instance.

public static implicit operator FilePath(FileInfo path)

Parameters

path FileInfo

Returns

FilePath

implicit operator FilePath(string)

Converts a path string to a FilePath instance.

public static implicit operator FilePath(string path)

Parameters

path string

Returns

FilePath