### SystemTempDirectory() Source: https://fornever.github.io/TruePath/api/TruePath.Temporary.html Gets the system's temporary directory and returns an AbsolutePath representing it. ```APIDOC ## SystemTempDirectory() ### Description Gets the system's temporary directory. ### Method SystemTempDirectory ### Signature public static AbsolutePath SystemTempDirectory() ### Returns - **AbsolutePath** - An AbsolutePath representing the system's temporary directory. ``` -------------------------------- ### LocalPath usage example Source: https://fornever.github.io/TruePath/index.html Shows basic LocalPath operations: creating a path, accessing its parent, and combining with a string or another LocalPath using the / operator. ```csharp var myRoot = new LocalPath("foo/bar"); var fooDirectory = myRoot.Parent; var bazSubdirectory = myRoot / "baz"; var alsoBazSubdirectory = myRoot / new LocalPath("baz"); __ ``` -------------------------------- ### StartsWith(LocalPath) Source: https://fornever.github.io/TruePath/api/TruePath.LocalPath.html Determines whether the current path starts with the specified path. ```APIDOC ## StartsWith(LocalPath) ### Description Determines whether the current path starts with the specified path. ### Method StartsWith ### Signature public bool StartsWith(LocalPath other) ### Parameters - **other** (LocalPath) - Required - The path to compare to the current path. ### Returns - **bool** - true if the current path starts with the specified path; otherwise, false. ### Remarks Checks for a non-strict prefix: if the paths are equal, then each still starts with the other, so every path starts with itself. ``` -------------------------------- ### StartsWith(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.AbsolutePath.html Determines whether the current path starts with the specified path. ```APIDOC ## StartsWith(AbsolutePath) ### Description Determines whether the current path starts with the specified path. ### Method StartsWith(AbsolutePath other) ### Signature public bool StartsWith(AbsolutePath other) ### Parameters - **other** (AbsolutePath) - Required - The path to compare to the current path. ### Returns - **bool** - true if the current path starts with the specified path; otherwise, false. ### Remarks Checks for a non-strict prefix: if the paths are equal, then each still starts with the other, so every path starts with itself. ``` -------------------------------- ### Value__ Source: https://fornever.github.io/TruePath/api/TruePath.LocalPath.html Gets the normalized path string. ```APIDOC ## Property: Value__ ### Description The normalized path string. ### Signature ```csharp public string Value { get; } ``` ### Property Value - **Type**: string ``` -------------------------------- ### PathRoot() Source: https://fornever.github.io/TruePath/api/TruePath.AbsolutePath.html Gets the root of this path. ```APIDOC ## PathRoot() ### Description Gets the root of this path. ### Method PathRoot() ### Signature public AbsolutePath PathRoot() ### Returns - **AbsolutePath** - The root of this path. ``` -------------------------------- ### CreateTempFolder(string?) Source: https://fornever.github.io/TruePath/api/TruePath.Temporary.html Creates a temporary folder with an optional prefix and returns an AbsolutePath representing the newly created temporary folder. ```APIDOC ## CreateTempFolder(string?) ### Description Creates a temporary folder with the specified prefix. ### Method CreateTempFolder ### Signature public static AbsolutePath CreateTempFolder(string? prefix = null) ### Parameters - **prefix** (string) - Optional - An optional string to add to the beginning of the subdirectory name. ### Returns - **AbsolutePath** - An AbsolutePath representing newly created temporary folder. ``` -------------------------------- ### AbsolutePath.Value Source: https://fornever.github.io/TruePath/api/TruePath.AbsolutePath.html Gets the normalized path string. ```APIDOC ## Property: AbsolutePath.Value ### Description Gets the normalized path string. ### Signature public string Value { get; } ### Property Value string ``` -------------------------------- ### Create(AbsolutePath, int, FileOptions) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates or overwrites a file with a buffer size and file options, returning a FileStream. ```APIDOC ## Create(AbsolutePath, int, FileOptions) ### Description Creates or overwrites a file in the specified path, specifying a buffer size and options that describe how to create or overwrite the file. ### Method Create ### Signature `public static FileStream Create(this AbsolutePath path, int bufferSize, FileOptions options)` ### Parameters - **path** (AbsolutePath) - Required - The path and name of the file to create. - **bufferSize** (int) - Required - The number of bytes buffered for reads and writes to the file. - **options** (FileOptions) - Required - One of the FileOptions values that describes how to create or overwrite the file. ### Returns - **FileStream** - A FileStream that provides read/write access to the file specified in path. ``` -------------------------------- ### FileName__ Source: https://fornever.github.io/TruePath/api/TruePath.LocalPath.html Gets the name of this path's last component. ```APIDOC ## Property: FileName__ ### Description The name of this path's last component. ### Signature ```csharp public string FileName { get; } ``` ### Property Value - **Type**: string ``` -------------------------------- ### AbsolutePath.FileName Source: https://fornever.github.io/TruePath/api/TruePath.AbsolutePath.html Gets the name of this path's last component. ```APIDOC ## Property: AbsolutePath.FileName ### Description Gets the name of this path's last component. ### Signature public string FileName { get; } ### Property Value string ``` -------------------------------- ### Create(AbsolutePath, int, FileOptions) overload Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates or overwrites a file with a specified buffer size and FileOptions, returning a FileStream with read/write access. ```csharp public static FileStream Create(this AbsolutePath path, int bufferSize, FileOptions options)__ ``` -------------------------------- ### GetExtensionWithDot(IPath) Source: https://fornever.github.io/TruePath/api/TruePath.PathExtensions.html Gets the extension of a path with the leading dot. ```APIDOC ## GetExtensionWithDot(IPath) ### Description Gets the extension of the file name of the `path` with the dot character. For example, for the path `file.txt`, this method returns `.txt`. File names entirely consisting of an extension, such as `.gitignore`, are returned as-is. ### Method Extension method ### Signature `public static string GetExtensionWithDot(this IPath path)` ### Parameters - **path** (IPath) - Required - The path to get the extension from. ### Returns - **string** - The extension of the file name of the path with the dot character (if present). ### Remarks This method returns an empty string for paths without extensions, and returns a dot for paths whose names end with a dot. This behavior allows distinguishing such paths and potentially reconstructing the file name from its part without the extension and the "extension with dot". ``` -------------------------------- ### CreateDirectory(AbsolutePath) method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates all directories and subdirectories in the specified path unless they already exist. ```csharp public static void CreateDirectory(this AbsolutePath path)__ ``` -------------------------------- ### AbsolutePath.CurrentWorkingDirectory Source: https://fornever.github.io/TruePath/api/TruePath.AbsolutePath.html Gets or sets the current working directory as an AbsolutePath instance. ```APIDOC ## Property: AbsolutePath.CurrentWorkingDirectory ### Description Gets or sets the current working directory as an AbsolutePath instance. ### Signature public static AbsolutePath CurrentWorkingDirectory { get; set; } ### Property Value AbsolutePath - The current working directory. ``` -------------------------------- ### Create(AbsolutePath, int) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates or overwrites a file with a specified buffer size and returns a FileStream. ```APIDOC ## Create(AbsolutePath, int) ### Description Creates, or truncates and overwrites, a file in the specified path, specifying a buffer size. ### Method Create ### Signature `public static FileStream Create(this AbsolutePath path, int bufferSize)` ### Parameters - **path** (AbsolutePath) - Required - The path and name of the file to create. - **bufferSize** (int) - Required - The number of bytes buffered for reads and writes to the file. ### Returns - **FileStream** - A FileStream that provides read/write access to the file specified in path. ``` -------------------------------- ### Open(AbsolutePath, FileMode, FileAccess, FileShare) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a FileStream on the specified path with the specified mode, access, and sharing option. Returns a FileStream with the specified sharing. ```csharp public static FileStream Open(this AbsolutePath path, FileMode mode, FileAccess access, FileShare share)__ ``` -------------------------------- ### GetFilenameWithoutExtension(IPath) Source: https://fornever.github.io/TruePath/api/TruePath.PathExtensions.html Gets the file name of a path without its extension. ```APIDOC ## GetFilenameWithoutExtension(IPath) ### Description Gets the file name of the `path` without the extension. For example, for the path `file.txt`, this method returns `file`. ### Method Extension method ### Signature `public static string GetFilenameWithoutExtension(this IPath path)` ### Parameters - **path** (IPath) - Required - The path to get the file name from. ### Returns - **string** - The file name of the path without the extension. If the path has no extension, the file name is returned as-is (one trailing dot will be stripped, though). ``` -------------------------------- ### GetExtensionWithoutDot(IPath) Source: https://fornever.github.io/TruePath/api/TruePath.PathExtensions.html Gets the extension of a path without the leading dot. ```APIDOC ## GetExtensionWithoutDot(IPath) ### Description Gets the extension of the file name of the `path` without the dot character. For example, for the path `file.txt`, this method returns `txt`. File names entirely consisting of an extension, such as `.gitignore`, are returned with the leading dot trimmed. ### Method Extension method ### Signature `public static string GetExtensionWithoutDot(this IPath path)` ### Parameters - **path** (IPath) - Required - The path to get the extension from. ### Returns - **string** - The extension of the file name of the path without the dot. ### Remarks This method returns an empty string for paths without extensions and with empty extensions (ending with a dot). This behavior does not allow distinguishing such paths using this method, so the original name cannot be reconstructed from its name without extension and its extension without dot. ``` -------------------------------- ### WriteAllText(AbsolutePath, string?, Encoding) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is truncated and overwritten. ```csharp public static void WriteAllText(this AbsolutePath path, string? contents, Encoding encoding)__ ``` -------------------------------- ### WriteAllText(AbsolutePath, string?) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates a new file, writes the specified string to the file, and then closes the file. If the target file already exists, it is truncated and overwritten. ```csharp public static void WriteAllText(this AbsolutePath path, string? contents)__ ``` -------------------------------- ### WriteAllLines(AbsolutePath, string[]) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates a new file, writes the specified string array to the file, and then closes the file. The path parameter is the file to write to and contents is the string array to write. ```csharp public static void WriteAllLines(this AbsolutePath path, string[] contents)__ ``` -------------------------------- ### Create(string) Source: https://fornever.github.io/TruePath/api/TruePath.LocalPath.html Creates a new LocalPath instance from the specified string value. ```APIDOC ## Create(string) ### Description Creates a new LocalPath instance from the specified string value. ### Method Create ### Signature public static LocalPath Create(string value) ### Parameters - **value** (string) - Required - The string representation of the path to create. ### Returns - **LocalPath** - A new normalized LocalPath instance representing the specified path. ``` -------------------------------- ### AbsolutePath.Parent Source: https://fornever.github.io/TruePath/api/TruePath.AbsolutePath.html Gets the parent of this path. Will be null for a rooted absolute path. For a relative path, will always resolve to its parent directory. ```APIDOC ## Property: AbsolutePath.Parent ### Description Gets the parent of this path. Will be null for a rooted absolute path. For a relative path, will always resolve to its parent directory — by either removing directories from the end of the path, or appending .. to the end. ### Signature public AbsolutePath? Parent { get; } ### Property Value AbsolutePath? ``` -------------------------------- ### ReadAllBytes(AbsolutePath) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a binary file, reads its contents into a byte array, and closes the file. Returns a byte array containing the file contents. ```csharp public static byte[] ReadAllBytes(this AbsolutePath path)__ ``` -------------------------------- ### CreateTempFile() Source: https://fornever.github.io/TruePath/api/TruePath.Temporary.html Creates a temporary file and returns an AbsolutePath representing the newly created temporary file. ```APIDOC ## CreateTempFile() ### Description Creates a temporary file. ### Method CreateTempFile ### Signature public static AbsolutePath CreateTempFile() ### Returns - **AbsolutePath** - An AbsolutePath representing the newly created temporary file. ``` -------------------------------- ### WriteAllLines(AbsolutePath, IEnumerable) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates a new file, writes a collection of strings to the file, and then closes the file. ```csharp public static void WriteAllLines(this AbsolutePath path, IEnumerable contents) ``` -------------------------------- ### Create(AbsolutePath, int) overload Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates or truncates and overwrites a file with a specified buffer size, returning a FileStream with read/write access. ```csharp public static FileStream Create(this AbsolutePath path, int bufferSize)__ ``` -------------------------------- ### WriteAllBytes(AbsolutePath, byte[]) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates a new file, writes the specified byte array, and closes the file. If the target file already exists, it is truncated and overwritten. ```csharp public static void WriteAllBytes(this AbsolutePath path, byte[] bytes) ``` -------------------------------- ### WriteAllLines(AbsolutePath, IEnumerable, Encoding) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates a new file using the specified encoding, writes a collection of strings to the file, and then closes the file. The path parameter is the file to write to, contents are the lines to write, and encoding is the character encoding to use. ```csharp public static void WriteAllLines(this AbsolutePath path, IEnumerable contents, Encoding encoding)__ ``` -------------------------------- ### EnumerateFiles(AbsolutePath, string) method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Returns an enumerable collection of AbsolutePath of full file names matching the search pattern. Uses Win32 semantics: '*' matches zero or more characters, '?' matches exactly one except before a period or at the end where it may match none. On .NET Framework, a three-character extension also matches longer ones. ```csharp public static IEnumerable EnumerateFiles(this AbsolutePath path, string searchPattern)__ ``` -------------------------------- ### Copy(AbsolutePath, AbsolutePath, bool) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Copies an existing file to a new file. Overwriting a file of the same name is allowed when overwrite is true. The destination cannot be a directory. ```csharp public static void Copy(this AbsolutePath sourceFile, AbsolutePath destFile, bool overwrite)__ ``` -------------------------------- ### Open(AbsolutePath, FileMode, FileAccess) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a FileStream on the specified path with the specified mode and access with no sharing. Returns a FileStream opened in the specified mode and path. ```csharp public static FileStream Open(this AbsolutePath path, FileMode mode, FileAccess access)__ ``` -------------------------------- ### CreateDirectory(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates all directories and subdirectories in the specified path unless they already exist. ```APIDOC ## CreateDirectory(AbsolutePath) ### Description Creates all directories and subdirectories in the specified path unless they already exist. ### Method CreateDirectory ### Signature `public static void CreateDirectory(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - Required - The directory to create. ``` -------------------------------- ### SetCreationTime(AbsolutePath, DateTime) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Sets the creation date and time of the file. The creationTime value is expressed in local time. ```csharp public static void SetCreationTime(this AbsolutePath path, DateTime creationTime) ``` -------------------------------- ### Create(string) Source: https://fornever.github.io/TruePath/api/TruePath.AbsolutePath.html Creates a new AbsolutePath instance from a string value. ```APIDOC ## Create(string) ### Description Creates a new path instance of type AbsolutePath from the specified string value. ### Method Create(string value) ### Signature public static AbsolutePath Create(string value) ### Parameters - **value** (string) - Required - The string representation of the path to create. ### Returns - **AbsolutePath** - A new instance of AbsolutePath representing the specified path. ``` -------------------------------- ### SetCreationTime(AbsolutePath, DateTime) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Sets the creation date and time of a file in local time. ```APIDOC ## SetCreationTime(AbsolutePath, DateTime) ### Description Sets the date and time the file was created. ### Method SetCreationTime ### Signature public static void SetCreationTime(this AbsolutePath path, DateTime creationTime) ### Parameters - **path** (AbsolutePath) - Required - The file for which to set the creation date and time information. - **creationTime** (DateTime) - Required - A DateTime containing the value to set for the creation date and time of `path`. This value is expressed in local time. ``` -------------------------------- ### LocalPathPattern(string) Source: https://fornever.github.io/TruePath/api/TruePath.LocalPathPattern.html Constructor for creating a LocalPathPattern instance with a pattern string. ```APIDOC ## LocalPathPattern Constructor ### Description Initializes a new instance of the LocalPathPattern struct with the specified pattern text. ### Signature ```csharp public LocalPathPattern(string Value) ``` ### Parameters - **Value** (string) - The pattern text. May be of various formats, such as a glob. This library does not dictate any particular format and gives no guarantees. ### Remarks This is a token type, created with the idea that it should be interpreted in a usage-specific way by some external means. ``` -------------------------------- ### CompareTo(LocalPath) Source: https://fornever.github.io/TruePath/api/TruePath.LocalPath.html Compares the current LocalPath instance with another LocalPath instance using platform-aware comparison rules. ```APIDOC ## CompareTo(LocalPath) ### Description Compares the current LocalPath instance with another LocalPath instance, using the default platform-aware comparison rules provided by TruePath.Comparers.PlatformDefaultPathComparer. ### Method CompareTo ### Signature public int CompareTo(LocalPath other) ### Parameters - **other** (LocalPath) - Required - The LocalPath instance to compare with the current instance. ### Returns - **int** - A signed integer that indicates the relative order of the compared objects. - Less than zero: The current instance precedes `other` in the sort order. - Zero: The current instance occurs in the same position in the sort order as `other`. - Greater than zero: The current instance follows `other` in the sort order. ``` -------------------------------- ### Copy(AbsolutePath, AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Copies an existing file to a new file. Overwriting a file of the same name is not allowed. The destination cannot be a directory or an existing file. ```csharp public static void Copy(this AbsolutePath sourceFile, AbsolutePath destFile)__ ``` -------------------------------- ### Path Comparison with StrictStringComparer Source: https://fornever.github.io/TruePath/index.html Shows how to use the StrictStringComparer overload of Equals to force case-sensitive comparison, and the default Equals which is platform-dependent. ```csharp var path1 = new LocalPath("a/b/c"); var path2 = new LocalPath("A/B/C"); var result1 = path1.Equals(path2, LocalPath.StrictStringComparer); // guaranteed to be false on all platforms var result2 = path1.Equals(path2); // might be true or false, depends on the current platform __ ``` -------------------------------- ### EnumerateFiles(AbsolutePath) method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Returns an enumerable collection of AbsolutePath of full file names in the specified directory. ```csharp public static IEnumerable EnumerateFiles(this AbsolutePath path)__ ``` -------------------------------- ### ReadAllText(AbsolutePath) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a text file, reads all text, and closes the file. Returns a string containing all the text. ```csharp public static string ReadAllText(this AbsolutePath path)__ ``` -------------------------------- ### ReadAllText(AbsolutePath, Encoding) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a text file, reads all text with the specified encoding, and closes the file. Returns a string containing all the text. ```csharp public static string ReadAllText(this AbsolutePath path, Encoding encoding)__ ``` -------------------------------- ### CompareTo(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.AbsolutePath.html Compares the current AbsolutePath instance with another AbsolutePath instance using the default platform-aware comparison rules. ```APIDOC ## CompareTo(AbsolutePath) ### Description Compares the current AbsolutePath instance with another AbsolutePath instance, using the default platform-aware comparison rules provided by TruePath.Comparers.PlatformDefaultPathComparer. ### Method CompareTo(AbsolutePath other) ### Signature public int CompareTo(AbsolutePath other) ### Parameters - **other** (AbsolutePath) - Required - The AbsolutePath instance to compare with the current instance. ### Returns - **int** - A signed integer that indicates the relative order of the compared objects. - Less than zero: The current instance precedes `other` in the sort order. - Zero: The current instance occurs in the same position in the sort order as `other`. - Greater than zero: The current instance follows `other` in the sort order. ``` -------------------------------- ### CreateText(AbsolutePath) method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates or opens a file for writing UTF-8 encoded text, replacing contents if the file already exists. Returns a StreamWriter. ```csharp public static StreamWriter CreateText(this AbsolutePath path)__ ``` -------------------------------- ### GetDirectories(AbsolutePath, string, SearchOption) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Extension method that returns subdirectory paths matching a search pattern and a SearchOption that controls whether to include subdirectories. ```csharp public static string[] GetDirectories(this AbsolutePath path, string searchPattern, SearchOption searchOption)__ ``` -------------------------------- ### Create(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates or overwrites a file at the specified path and returns a FileStream for read/write access. ```APIDOC ## Create(AbsolutePath) ### Description Creates, or truncates and overwrites, a file in the specified path. ### Method Create ### Signature `public static FileStream Create(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - Required - The path and name of the file to create. ### Returns - **FileStream** - A FileStream that provides read/write access to the file specified in path. ``` -------------------------------- ### ReadAllLines(AbsolutePath, Encoding) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a file, reads all lines with the specified encoding, and closes the file. Returns a string array containing all lines. ```csharp public static string[] ReadAllLines(this AbsolutePath path, Encoding encoding)__ ``` -------------------------------- ### ReadAllLines(AbsolutePath) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a text file, reads all lines, and closes the file. Returns a string array containing all lines. ```csharp public static string[] ReadAllLines(this AbsolutePath path)__ ``` -------------------------------- ### AbsolutePath(string) Source: https://fornever.github.io/TruePath/api/TruePath.AbsolutePath.html Constructor that creates an AbsolutePath instance from a string path, normalizing it according to LocalPath rules. ```APIDOC ## AbsolutePath(string) ### Description Creates an AbsolutePath instance by normalizing the path from the passed string according to the rules stated in LocalPath. ### Method Constructor ### Parameters - `value` (string) - Required - Path string to normalize. ### Exceptions - ArgumentException - Thrown if the passed string does not represent an absolute path. ``` -------------------------------- ### Open(AbsolutePath, FileMode, FileAccess, FileShare) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a FileStream on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. ```APIDOC ## Open(AbsolutePath, FileMode, FileAccess, FileShare) ### Description Opens a FileStream on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. ### Method Open ### Signature `public static FileStream Open(this AbsolutePath path, FileMode mode, FileAccess access, FileShare share)` ### Parameters - **path** (AbsolutePath) - The file to open. - **mode** (FileMode) - A FileMode value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. - **access** (FileAccess) - A FileAccess value that specifies the operations that can be performed on the file. - **share** (FileShare) - A FileShare value specifying the type of access other threads have to the file. ### Returns FileStream - A FileStream on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. ``` -------------------------------- ### ReadAllBytes(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a binary file, reads the contents of the file into a byte array, and then closes the file. ```APIDOC ## ReadAllBytes(AbsolutePath) ### Description Opens a binary file, reads the contents of the file into a byte array, and then closes the file. ### Method ReadAllBytes ### Signature `public static byte[] ReadAllBytes(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - The file to open for reading. ### Returns byte[] - A byte array containing the contents of the file. ``` -------------------------------- ### AppendAllText(AbsolutePath, string?) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Appends the specified string to the file, creating the file if it does not already exist. The file handle is guaranteed to be closed even if exceptions are raised. The method does not create new directories, so the path must contain existing directories. ```csharp public static void AppendAllText(this AbsolutePath path, string? contents)__ ``` -------------------------------- ### CreateText(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates or opens a file for writing UTF-8 text and returns a StreamWriter. ```APIDOC ## CreateText(AbsolutePath) ### Description Creates or opens a file for writing UTF-8 encoded text. If the file already exists, its contents are replaced. ### Method CreateText ### Signature `public static StreamWriter CreateText(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - Required - The file to be opened for writing. ### Returns - **StreamWriter** - A StreamWriter that writes to the specified file using UTF-8 encoding. ``` -------------------------------- ### WriteAllLines(AbsolutePath, IEnumerable) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Writes a collection of strings to a file, creating a new file. ```APIDOC ## WriteAllLines(AbsolutePath, IEnumerable) ### Description Creates a new file, writes a collection of strings to the file, and then closes the file. ### Method WriteAllLines ### Signature public static void WriteAllLines(this AbsolutePath path, IEnumerable contents) ### Parameters - **path** (AbsolutePath) - Required - The file to write to. - **contents** (IEnumerable) - Required - The lines to write to the file. ``` -------------------------------- ### SetCreationTimeUtc(AbsolutePath, DateTime) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Sets the creation date and time of a file in UTC. ```APIDOC ## SetCreationTimeUtc(AbsolutePath, DateTime) ### Description Sets the date and time, in Coordinated Universal Time (UTC), that the file was created. ### Method SetCreationTimeUtc ### Signature public static void SetCreationTimeUtc(this AbsolutePath path, DateTime creationTimeUtc) ### Parameters - **path** (AbsolutePath) - Required - The file for which to set the creation date and time information. - **creationTimeUtc** (DateTime) - Required - The value to set for the creation date and time of `path`. This value is expressed in UTC time. ``` -------------------------------- ### SetCreationTimeUtc(AbsolutePath, DateTime) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Sets the creation date and time of the file in Coordinated Universal Time (UTC). The creationTimeUtc value is expressed in UTC. ```csharp public static void SetCreationTimeUtc(this AbsolutePath path, DateTime creationTimeUtc) ``` -------------------------------- ### OpenRead(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens an existing file for reading. ```APIDOC ## OpenRead(AbsolutePath) ### Description Opens an existing file for reading. ### Method OpenRead ### Signature `public static FileStream OpenRead(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - The file to be opened for reading. ### Returns FileStream - A read-only FileStream on the specified path. ``` -------------------------------- ### Create(AbsolutePath) overload Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates or truncates and overwrites a file at the specified path, returning a FileStream with read/write access. ```csharp public static FileStream Create(this AbsolutePath path)__ ``` -------------------------------- ### GetCreationTime(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Extension method that returns the creation time of a file or directory in local time. ```APIDOC ## GetCreationTime(AbsolutePath) ### Description Returns the creation date and time of the specified file or directory. ### Method Extension method ### Signature `public static DateTime GetCreationTime(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - The file or directory for which to obtain creation date and time information. ### Returns - **DateTime** - A DateTime structure set to the creation date and time for the specified file or directory. This value is expressed in local time. ``` -------------------------------- ### OpenWrite(AbsolutePath) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens an existing file or creates a new file for writing. Returns an unshared FileStream with Write access. ```csharp public static FileStream OpenWrite(this AbsolutePath path)__ ``` -------------------------------- ### GetCreationTimeUtc(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Extension method that returns the creation time of a file or directory in UTC. ```APIDOC ## GetCreationTimeUtc(AbsolutePath) ### Description Returns the creation date and time, in Coordinated Universal Time (UTC), of the specified file or directory. ### Method Extension method ### Signature `public static DateTime GetCreationTimeUtc(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - The file or directory for which to obtain creation date and time information. ### Returns - **DateTime** - A DateTime structure set to the creation date and time for the specified file or directory. This value is expressed in UTC time. ``` -------------------------------- ### Open(AbsolutePath, FileMode, FileAccess) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a FileStream on the specified path with the specified mode and access with no sharing. ```APIDOC ## Open(AbsolutePath, FileMode, FileAccess) ### Description Opens a FileStream on the specified path with the specified mode and access with no sharing. ### Method Open ### Signature `public static FileStream Open(this AbsolutePath path, FileMode mode, FileAccess access)` ### Parameters - **path** (AbsolutePath) - The file to open. - **mode** (FileMode) - A FileMode value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. - **access** (FileAccess) - A FileAccess value that specifies the operations that can be performed on the file. ### Returns FileStream - A FileStream opened in the specified mode and path, with the specified mode and access with no sharing. ``` -------------------------------- ### AppendAllText(AbsolutePath, string?, Encoding) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Appends the specified string to the file using the specified encoding, creating the file if it does not already exist. The file handle is guaranteed to be closed even if exceptions are raised. The method does not create new directories, so the path must contain existing directories. ```csharp public static void AppendAllText(this AbsolutePath path, string? contents, Encoding encoding)__ ``` -------------------------------- ### Copy(AbsolutePath, AbsolutePath, bool) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Copies a file to a new file, optionally overwriting an existing file. ```APIDOC ## Copy(AbsolutePath, AbsolutePath, bool) ### Description Copies an existing file to a new file. Overwriting a file of the same name is allowed. ### Method Copy ### Signature public static void Copy(this AbsolutePath sourceFile, AbsolutePath destFile, bool overwrite) ### Parameters - **sourceFile** (AbsolutePath) - Required - The file to copy. - **destFile** (AbsolutePath) - Required - The name of the destination file. This cannot be a directory. - **overwrite** (bool) - Required - **true** if the destination file should be replaced if it already exists; otherwise, **false**. ``` -------------------------------- ### EnumerateFiles(AbsolutePath, string) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Enumerates files in a directory that match a search pattern and returns their full paths. ```APIDOC ## EnumerateFiles(AbsolutePath, string) ### Description Returns an enumerable collection of AbsolutePath of full file names in a specified path that match a search pattern. ### Method EnumerateFiles ### Signature `public static IEnumerable EnumerateFiles(this AbsolutePath path, string searchPattern)` ### Parameters - **path** (AbsolutePath) - Required - The directory to search. - **searchPattern** (string) - Required - The search string to match against the names of files in `path`. It may combine literal characters with the `*` and `?` wildcards, but it does not support regular expressions. This overload matches with Win32 semantics, where `*` stands for zero or more characters and `?` for exactly one, except immediately before a period or at the end of the name, where it may also match none: `a?.txt` matches both `ab.txt` and `a.txt`, while `?ello.txt` matches only `hello.txt`. When running on .NET Framework, a three-character extension also matches longer ones, so `*.txt` additionally matches `hello.txtt`. For the full pattern syntax and its caveats, see https://learn.microsoft.com/dotnet/api/system.io.directory.enumeratefiles. ### Returns - **IEnumerable** - An enumerable collection of AbsolutePath of the full names (including paths) for the files in the specified directory that match the specified search pattern. ``` -------------------------------- ### WriteAllLines(AbsolutePath, string[], Encoding) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Creates a new file, writes the specified string array to the file using the specified encoding, and then closes the file. The encoding parameter is an Encoding object that represents the character encoding applied to the string array. ```csharp public static void WriteAllLines(this AbsolutePath path, string[] contents, Encoding encoding)__ ``` -------------------------------- ### EnumerateFiles(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Enumerates all files in the specified directory and returns their full paths. ```APIDOC ## EnumerateFiles(AbsolutePath) ### Description Returns an enumerable collection of AbsolutePath of full file names in a specified path. ### Method EnumerateFiles ### Signature `public static IEnumerable EnumerateFiles(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - Required - The directory to search. ### Returns - **IEnumerable** - An enumerable collection of AbsolutePath of the full names (including paths) for the files in the specified directory. ``` -------------------------------- ### ReadAllText(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a text file, reads all the text in the file, and then closes the file. ```APIDOC ## ReadAllText(AbsolutePath) ### Description Opens a text file, reads all the text in the file, and then closes the file. ### Method ReadAllText ### Signature `public static string ReadAllText(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - The file to open for reading. ### Returns string - A string containing all the text in the file. ``` -------------------------------- ### EnumerateFiles(AbsolutePath, string, SearchOption) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Extension method that enumerates files in a directory matching a search pattern, optionally searching subdirectories. ```APIDOC ## EnumerateFiles(AbsolutePath, string, SearchOption) ### Description Returns an enumerable collection of AbsolutePath with the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories. ### Method Extension method ### Signature `public static IEnumerable EnumerateFiles(this AbsolutePath path, string searchPattern, SearchOption searchOption)` ### Parameters - **path** (AbsolutePath) - The directory to search. - **searchPattern** (string) - The search string to match against the names of files in `path`. It may combine literal characters with the `*` and `?` wildcards, but it does not support regular expressions. This overload matches with Win32 semantics, where `*` stands for zero or more characters and `?` for exactly one, except immediately before a period or at the end of the name, where it may also match none: `a?.txt` matches both `ab.txt` and `a.txt`, while `?ello.txt` matches only `hello.txt`. When running on .NET Framework, a three-character extension also matches longer ones, so `*.txt` additionally matches `hello.txtt`. For the full pattern syntax and its caveats, see https://learn.microsoft.com/dotnet/api/system.io.directory.enumeratefiles. - **searchOption** (SearchOption) - One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories. ### Returns - **IEnumerable** - An enumerable collection of AbsolutePath of the full names (including paths) for the files in the specified directory that match the specified search pattern and option. ``` -------------------------------- ### ReadAllText(AbsolutePath, Encoding) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a text file, reads all the text in the file, and then closes the file. ```APIDOC ## ReadAllText(AbsolutePath, Encoding) ### Description Opens a text file, reads all the text in the file, and then closes the file. ### Method ReadAllText ### Signature `public static string ReadAllText(this AbsolutePath path, Encoding encoding)` ### Parameters - **path** (AbsolutePath) - The file to open for reading. - **encoding** (Encoding) - The encoding that is applied to the contents of the file. ### Returns string - A string containing all the text in the file. ``` -------------------------------- ### OpenWrite(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens an existing file or creates a new file for writing. ```APIDOC ## OpenWrite(AbsolutePath) ### Description Opens an existing file or creates a new file for writing. ### Method OpenWrite ### Signature `public static FileStream OpenWrite(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - The file to be opened for writing. ### Returns FileStream - An unshared FileStream object on the specified path with Write access. ``` -------------------------------- ### Open(AbsolutePath, FileMode) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a FileStream on the specified path with read/write access with no sharing. ```APIDOC ## Open(AbsolutePath, FileMode) ### Description Opens a FileStream on the specified path with read/write access with no sharing. ### Method Extension method ### Signature `public static FileStream Open(this AbsolutePath path, FileMode mode)` ### Parameters - **path** (AbsolutePath) - Required - The file to open. - **mode** (FileMode) - Required - A FileMode value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. ### Returns - **FileStream** - A FileStream opened in the specified mode and path, with read/write access and not shared. ``` -------------------------------- ### GetDirectories(AbsolutePath, string, SearchOption) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories. ```APIDOC ## GetDirectories(AbsolutePath, string, SearchOption) ### Description Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories. ### Method Extension method ### Signature `public static string[] GetDirectories(this AbsolutePath path, string searchPattern, SearchOption searchOption)` ### Parameters - **path** (AbsolutePath) - Required - The directory to search. - **searchPattern** (string) - Required - The search string to match against the names of subdirectories in `path`. It may combine literal characters with the `*` and `?` wildcards, but it does not support regular expressions. This overload matches with Win32 semantics, where `*` stands for zero or more characters and `?` for exactly one, except immediately before a period or at the end of the name, where it may also match none: `a?` matches both `ab` and `a`. For the full pattern syntax and its caveats, see https://learn.microsoft.com/dotnet/api/system.io.directory.getdirectories. - **searchOption** (SearchOption) - Required - One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories. ### Returns - **string[]** - An array of the full names (including paths) for the subdirectories in the specified directory that match the specified search pattern and option. ``` -------------------------------- ### ReadAllLines(AbsolutePath) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens a text file, reads all lines of the file, and then closes the file. ```APIDOC ## ReadAllLines(AbsolutePath) ### Description Opens a text file, reads all lines of the file, and then closes the file. ### Method ReadAllLines ### Signature `public static string[] ReadAllLines(this AbsolutePath path)` ### Parameters - **path** (AbsolutePath) - The file to open for reading. ### Returns string[] - A string array containing all lines of the file. ``` -------------------------------- ### OpenText(AbsolutePath) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Opens an existing UTF-8 encoded text file for reading. Returns a StreamReader on the specified path. ```csharp public static StreamReader OpenText(this AbsolutePath path)__ ``` -------------------------------- ### WithExtension(LocalPath, string?) Source: https://fornever.github.io/TruePath/api/TruePath.PathExtensions.html Changes the extension of a LocalPath. ```APIDOC ## WithExtension(LocalPath, string?) ### Description Returns a new path of type LocalPath with the extension of its file name component changed, or with a new extension-like component if the original file name was empty. ### Method Extension method ### Signature `public static LocalPath WithExtension(this LocalPath path, string? extension)` ### Parameters - **path** (LocalPath) - Required - The original path. - **extension** (string?) - Required - The new extension, either with or without the leading dot: both `txt` and `.txt` give the same result, since the dot is added when missing. Pass null to remove the extension entirely (`file.txt` becomes `file`), or an empty string to remove it but keep the trailing dot (`file.txt` becomes `file.`). ### Returns - **LocalPath** - A new path of type LocalPath with the modified file name component. The original `path` object is not modified. ### Remarks Only the last extension is replaced: for `archive.tar.gz` and the extension `zip`, the result is `archive.tar.zip`. The extension itself may contain dots, so `.tar.gz` applied to `archive.zip` gives `archive.tar.gz`. If the file name has no extension, the new one is appended: `file` becomes `file.txt`. A file name consisting entirely of an extension is treated as an extension, consistently with GetExtensionWithDot(IPath): `.gitignore` with the extension `hgignore` becomes `.hgignore`. ``` -------------------------------- ### GetDirectories(AbsolutePath) extension method Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Extension method on AbsolutePath that returns the full paths of subdirectories in the specified directory. ```csharp public static string[] GetDirectories(this AbsolutePath path)__ ``` -------------------------------- ### AppendAllLines(AbsolutePath, IEnumerable) Source: https://fornever.github.io/TruePath/api/TruePath.SystemIo.PathIo.html Appends lines to a file, creating it if it does not exist. ```APIDOC ## AppendAllLines(AbsolutePath, IEnumerable) ### Description Appends the specified lines to the file, creating the file if it does not already exist. ### Method AppendAllLines ### Signature public static void AppendAllLines(this AbsolutePath path, IEnumerable contents) ### Parameters - **path** (AbsolutePath) - The file to append to. - **contents** (IEnumerable) - The lines to write to the file. ### Remarks Given a sequence of strings and a file path, this method opens the specified file, appends each string as a line to the end of the file using the specified encoding, and then closes the file. The file handle is guaranteed to be closed by this method, even if exceptions are raised. The method creates the file if it doesn't exist, but it doesn't create new directories. Therefore, the value of the path parameter must contain existing directories. ### Exceptions - **ArgumentNullException** - `path` is null. - **ArgumentException** - `path` is empty. - **PathTooLongException** - The specified path, file name, or both exceed the system-defined maximum length. - **DirectoryNotFoundException** - The specified path is invalid (for example, it is on an unmapped drive). - **IOException** - An I/O error occurred while opening the file. - **UnauthorizedAccessException** - `path` specified a file that is read-only. - **UnauthorizedAccessException** - `path` specified a file that is hidden. - **UnauthorizedAccessException** - `path` specified a directory. - **UnauthorizedAccessException** - This operation is not supported on the current platform. - **UnauthorizedAccessException** - The caller does not have the required permission. - **NotSupportedException** - `path` is in an invalid format. ```