Class PathIo
Extension methods for the AbsolutePath type that provide common I/O operations.
public static class PathIo
- Inheritance
-
PathIo
- Inherited Members
Methods
AppendAllLines(AbsolutePath, IEnumerable<string>)
Appends the specified lines to the file, creating the file if it does not already exist.
public static void AppendAllLines(this AbsolutePath path, IEnumerable<string> contents)
Parameters
pathAbsolutePathThe file to append to.
contentsIEnumerable<string>The lines to write to the file.
Remarks
Given a sequence of strings and a file path, this method opens the specified file, appends the 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
pathis null.- ArgumentException
pathis 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
pathspecified a file that is read-only.- UnauthorizedAccessException
pathspecified a file that is hidden.- UnauthorizedAccessException
pathspecified a directory.- UnauthorizedAccessException
This operation is not supported on the current platform.
- UnauthorizedAccessException
The caller does not have the required permission.
- NotSupportedException
pathis in an invalid format.
AppendAllLines(AbsolutePath, IEnumerable<string>, Encoding)
Appends the specified lines to the file, creating the file if it does not already exist.
public static void AppendAllLines(this AbsolutePath path, IEnumerable<string> contents, Encoding encoding)
Parameters
pathAbsolutePathThe file to append to.
contentsIEnumerable<string>The lines to write to the file.
encodingEncodingThe encoding to apply to the each line.
Remarks
Given a sequence of strings and a file path, this method opens the specified file, appends the 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
pathis null.- ArgumentException
pathis empty.- ArgumentNullException
encodingis null.- 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
pathspecified a file that is read-only.- UnauthorizedAccessException
pathspecified a file that is hidden.- UnauthorizedAccessException
pathspecified a directory.- UnauthorizedAccessException
This operation is not supported on the current platform.
- UnauthorizedAccessException
The caller does not have the required permission.
- NotSupportedException
pathis in an invalid format.
AppendAllText(AbsolutePath, string?)
Appends the specified string to the file, creating the file if it does not already exist.
public static void AppendAllText(this AbsolutePath path, string? contents)
Parameters
pathAbsolutePathThe file to append to.
contentsstringThe characters to write to the file.
Remarks
Given a string and a file path, this method opens the specified file, appends the string 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
pathis null.- ArgumentException
pathis 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
pathspecified a file that is read-only.- UnauthorizedAccessException
pathspecified a file that is hidden.- UnauthorizedAccessException
pathspecified a directory.- UnauthorizedAccessException
This operation is not supported on the current platform.
- UnauthorizedAccessException
The caller does not have the required permission.
- NotSupportedException
pathis in an invalid format.
AppendAllText(AbsolutePath, string?, Encoding)
Appends the specified string to the file, creating the file if it does not already exist.
public static void AppendAllText(this AbsolutePath path, string? contents, Encoding encoding)
Parameters
pathAbsolutePathThe file to append to.
contentsstringThe characters to write to the file.
encodingEncodingThe encoding to apply to the string.
Remarks
Given a string and a file path, this method opens the specified file, appends the string 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
pathis null.- ArgumentException
pathis empty.- ArgumentNullException
encodingis null.- 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
pathspecified a file that is read-only.- UnauthorizedAccessException
pathspecified a file that is hidden.- UnauthorizedAccessException
pathspecified a directory.- UnauthorizedAccessException
This operation is not supported on the current platform.
- UnauthorizedAccessException
The caller does not have the required permission.
- NotSupportedException
pathis in an invalid format.
AppendText(AbsolutePath)
Creates a StreamWriter that appends UTF-8 encoded text to an existing file, or to a new file if the specified file does not exist.
public static StreamWriter AppendText(this AbsolutePath path)
Parameters
pathAbsolutePathThe path to the file to append to.
Returns
- StreamWriter
A stream writer that appends UTF-8 encoded text to the specified file or to a new file.
Copy(AbsolutePath, AbsolutePath)
Copies an existing file to a new file. Overwriting a file of the same name is not allowed.
public static void Copy(this AbsolutePath sourceFile, AbsolutePath destFile)
Parameters
sourceFileAbsolutePathThe file to copy.
destFileAbsolutePathThe name of the destination file. This cannot be a directory or an existing file.
Copy(AbsolutePath, AbsolutePath, bool)
Copies an existing file to a new file. Overwriting a file of the same name is allowed.
public static void Copy(this AbsolutePath sourceFile, AbsolutePath destFile, bool overwrite)
Parameters
sourceFileAbsolutePathThe file to copy.
destFileAbsolutePathThe name of the destination file. This cannot be a directory.
overwritebooltrue if the destination file should be replaced if it already exists; otherwise, false.
Create(AbsolutePath)
Creates, or truncates and overwrites, a file in the specified path.
public static FileStream Create(this AbsolutePath path)
Parameters
pathAbsolutePathThe path and name of the file to create.
Returns
- FileStream
A FileStream that provides read/write access to the file specified in path.
Create(AbsolutePath, int)
Creates, or truncates and overwrites, a file in the specified path, specifying a buffer size.
public static FileStream Create(this AbsolutePath path, int bufferSize)
Parameters
pathAbsolutePathThe path and name of the file to create.
bufferSizeintThe 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.
Create(AbsolutePath, int, FileOptions)
Creates or overwrites a file in the specified path, specifying a buffer size and options that describe how to create or overwrite the file.
public static FileStream Create(this AbsolutePath path, int bufferSize, FileOptions options)
Parameters
pathAbsolutePathThe path and name of the file to create.
bufferSizeintThe number of bytes buffered for reads and writes to the file.
optionsFileOptionsOne 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.
CreateDirectory(AbsolutePath)
Creates all directories and subdirectories in the specified path unless they already exist.
public static void CreateDirectory(this AbsolutePath path)
Parameters
pathAbsolutePathThe directory to create.
CreateText(AbsolutePath)
Creates or opens a file for writing UTF-8 encoded text. If the file already exists, its contents are replaced.
public static StreamWriter CreateText(this AbsolutePath path)
Parameters
pathAbsolutePathThe file to be opened for writing.
Returns
- StreamWriter
A StreamWriter that writes to the specified file using UTF-8 encoding.
Delete(AbsolutePath)
Deletes the specified file or directory.
public static void Delete(this AbsolutePath path)
Parameters
pathAbsolutePathThe name of the file to be deleted. Wildcard characters are not supported.
DeleteDirectoryRecursively(AbsolutePath)
Deletes the specified directory and any subdirectories and files in the directory.
public static void DeleteDirectoryRecursively(this AbsolutePath path)
Parameters
pathAbsolutePathThe name of the directory to remove. This directory must be writable.
DeleteEmptyDirectory(AbsolutePath)
Deletes the specified empty directory.
public static void DeleteEmptyDirectory(this AbsolutePath path)
Parameters
pathAbsolutePathThe name of the directory to remove. This directory must be writable and empty.
Exists(AbsolutePath)
Determines whether the specified file exists.
public static bool Exists(this AbsolutePath path)
Parameters
pathAbsolutePathThe file to check.
Returns
- bool
true if the caller has the required permissions and
pathcontains the name of an existing file; otherwise, false. This method also returns false ifpathis null, an invalid path, or a zero-length string. If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns false regardless of the existence ofpath.
ExistsDirectory(AbsolutePath)
Determines whether the given path refers to an existing directory on disk.
public static bool ExistsDirectory(this AbsolutePath path)
Parameters
pathAbsolutePathThe path to test.
Returns
- bool
true if path refers to an existing directory; false if the directory does not exist or an error occurs when trying to determine if the specified directory exists.
GetAttributes(AbsolutePath)
Gets the FileAttributes of the file on the path.
public static FileAttributes GetAttributes(this AbsolutePath path)
Parameters
pathAbsolutePathThe path to the file.
Returns
- FileAttributes
The FileAttributes of the file on the path.
GetCreationTime(AbsolutePath)
Returns the creation date and time of the specified file or directory.
public static DateTime GetCreationTime(this AbsolutePath path)
Parameters
pathAbsolutePathThe 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.
GetCreationTimeUtc(AbsolutePath)
Returns the creation date and time, in Coordinated Universal Time (UTC), of the specified file or directory.
public static DateTime GetCreationTimeUtc(this AbsolutePath path)
Parameters
pathAbsolutePathThe 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.
GetDirectories(AbsolutePath)
Returns the names of subdirectories (including their paths) in the specified directory.
public static string[] GetDirectories(this AbsolutePath path)
Parameters
pathAbsolutePathThe directory to search.
Returns
- string[]
An array of the full names (including paths) for the subdirectories in the specified directory.
GetDirectories(AbsolutePath, string)
Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory.
public static string[] GetDirectories(this AbsolutePath path, string searchPattern)
Parameters
pathAbsolutePathThe directory to search.
searchPatternstringThe search string to match against the names of subdirectories in
path.
Returns
- string[]
An array of the full names (including paths) for the subdirectories in the specified directory that match the specified search pattern.
GetDirectories(AbsolutePath, string, SearchOption)
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.
public static string[] GetDirectories(this AbsolutePath path, string searchPattern, SearchOption searchOption)
Parameters
pathAbsolutePathThe directory to search.
searchPatternstringThe search string to match against the names of subdirectories in
path.searchOptionSearchOptionOne 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.
GetFiles(AbsolutePath)
Returns the names of files (including their paths) that match the specified search pattern in the specified directory.
public static string[] GetFiles(this AbsolutePath path)
Parameters
pathAbsolutePathThe directory to search.
Returns
- string[]
An array of the full names (including paths) for the files in the specified directory that match the specified search pattern.
GetFiles(AbsolutePath, string)
Returns the names of files (including their paths) that match the specified search pattern in the specified directory.
public static string[] GetFiles(this AbsolutePath path, string searchPattern)
Parameters
pathAbsolutePathThe directory to search.
searchPatternstringThe search string to match against the names of files in
path.
Returns
- string[]
An array of the full names (including paths) for the files in the specified directory that match the specified search pattern.
GetFiles(AbsolutePath, string, SearchOption)
Returns 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.
public static string[] GetFiles(this AbsolutePath path, string searchPattern, SearchOption searchOption)
Parameters
pathAbsolutePathThe directory to search.
searchPatternstringThe search string to match against the names of files in
path.searchOptionSearchOptionOne 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 files in the specified directory that match the specified search pattern and option.
GetLastAccessTime(AbsolutePath)
Returns the date and time the specified file or directory was last accessed.
public static DateTime GetLastAccessTime(this AbsolutePath path)
Parameters
pathAbsolutePathThe file or directory for which to obtain access date and time information.
Returns
- DateTime
A DateTime structure set to the date and time that the specified file or directory was last accessed. This value is expressed in local time.
GetLastAccessTimeUtc(AbsolutePath)
Returns the date and time, in Coordinated Universal Time (UTC), that the specified file or directory was last accessed.
public static DateTime GetLastAccessTimeUtc(this AbsolutePath path)
Parameters
pathAbsolutePathThe file or directory for which to obtain access date and time information.
Returns
- DateTime
A DateTime structure set to the date and time that the specified file or directory was last accessed. This value is expressed in UTC time.
GetLastWriteTime(AbsolutePath)
Returns the date and time the specified file or directory was last written to.
public static DateTime GetLastWriteTime(this AbsolutePath path)
Parameters
pathAbsolutePathThe file or directory for which to obtain write date and time information.
Returns
- DateTime
A DateTime structure set to the date and time that the specified file or directory was last written to. This value is expressed in local time.
GetLastWriteTimeUtc(AbsolutePath)
Returns the date and time, in Coordinated Universal Time (UTC), that the specified file or directory was last written to.
public static DateTime GetLastWriteTimeUtc(this AbsolutePath path)
Parameters
pathAbsolutePathThe file or directory for which to obtain write date and time information.
Returns
- DateTime
A DateTime structure set to the date and time that the specified file or directory was last written to. This value is expressed in UTC time.
Move(AbsolutePath, AbsolutePath)
Moves a specified file to a new location, providing the option to specify a new file name.
public static void Move(this AbsolutePath sourceFile, AbsolutePath destFile)
Parameters
sourceFileAbsolutePathThe name of the file to move. Can include a relative or absolute path.
destFileAbsolutePathThe new path and name for the file.
Open(AbsolutePath, FileMode)
Opens a FileStream on the specified path with read/write access with no sharing.
public static FileStream Open(this AbsolutePath path, FileMode mode)
Parameters
pathAbsolutePathThe file to open.
modeFileModeA 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.
Open(AbsolutePath, FileMode, FileAccess)
Opens a FileStream on the specified path with the specified mode and access with no sharing.
public static FileStream Open(this AbsolutePath path, FileMode mode, FileAccess access)
Parameters
pathAbsolutePathThe file to open.
modeFileModeA 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.
accessFileAccessA 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.
Open(AbsolutePath, FileMode, FileAccess, FileShare)
Opens a FileStream on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option.
public static FileStream Open(this AbsolutePath path, FileMode mode, FileAccess access, FileShare share)
Parameters
pathAbsolutePathThe file to open.
modeFileModeA 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.
accessFileAccessA FileAccess value that specifies the operations that can be performed on the file.
shareFileShareA 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.
OpenRead(AbsolutePath)
Opens an existing file for reading.
public static FileStream OpenRead(this AbsolutePath path)
Parameters
pathAbsolutePathThe file to be opened for reading.
Returns
- FileStream
A read-only FileStream on the specified path.
OpenText(AbsolutePath)
Opens an existing UTF-8 encoded text file for reading.
public static StreamReader OpenText(this AbsolutePath path)
Parameters
pathAbsolutePathThe file to be opened for reading.
Returns
- StreamReader
A StreamReader on the specified path.
OpenWrite(AbsolutePath)
Opens an existing file or creates a new file for writing.
public static FileStream OpenWrite(this AbsolutePath path)
Parameters
pathAbsolutePathThe file to be opened for writing.
Returns
- FileStream
An unshared FileStream object on the specified path with Write access.
ReadAllBytes(AbsolutePath)
Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
public static byte[] ReadAllBytes(this AbsolutePath path)
Parameters
pathAbsolutePathThe file to open for reading.
Returns
- byte[]
A byte array containing the contents of the file.
ReadAllLines(AbsolutePath)
Opens a text file, reads all lines of the file, and then closes the file.
public static string[] ReadAllLines(this AbsolutePath path)
Parameters
pathAbsolutePathThe file to open for reading.
Returns
- string[]
A string array containing all lines of the file.
ReadAllLines(AbsolutePath, Encoding)
Opens a file, reads all lines of the file with the specified encoding, and then closes the file.
public static string[] ReadAllLines(this AbsolutePath path, Encoding encoding)
Parameters
pathAbsolutePathThe file to open for reading.
encodingEncodingThe encoding applied to the contents of the file.
Returns
- string[]
A string array containing all lines of the file.
ReadAllText(AbsolutePath)
Opens a text file, reads all the text in the file, and then closes the file.
public static string ReadAllText(this AbsolutePath path)
Parameters
pathAbsolutePathThe file to open for reading.
Returns
- string
A string containing all the text in the file.
ReadAllText(AbsolutePath, Encoding)
Opens a text file, reads all the text in the file, and then closes the file.
public static string ReadAllText(this AbsolutePath path, Encoding encoding)
Parameters
pathAbsolutePathThe file to open for reading.
encodingEncodingThe encoding that is applied to the contents of the file.
Returns
- string
A string containing all the text in the file.
ReadLines(AbsolutePath)
Reads the lines of a file.
public static IEnumerable<string> ReadLines(this AbsolutePath path)
Parameters
pathAbsolutePathThe file to read.
Returns
- IEnumerable<string>
All the lines of the file, or the lines that are the result of a query.
ReadLines(AbsolutePath, Encoding)
Read the lines of a file that has a specified encoding.
public static IEnumerable<string> ReadLines(this AbsolutePath path, Encoding encoding)
Parameters
pathAbsolutePathThe file to read.
encodingEncodingThe encoding that is applied to the contents of the file.
Returns
- IEnumerable<string>
All the lines of the file, or the lines that are the result of a query.
SetAttributes(AbsolutePath, FileAttributes)
Sets the specified FileAttributes of the file on the specified path.
public static void SetAttributes(this AbsolutePath path, FileAttributes fileAttributes)
Parameters
pathAbsolutePathThe path to the file.
fileAttributesFileAttributesA bitwise combination of the enumeration values.
SetCreationTime(AbsolutePath, DateTime)
Sets the date and time the file was created.
public static void SetCreationTime(this AbsolutePath path, DateTime creationTime)
Parameters
pathAbsolutePathThe file for which to set the creation date and time information.
creationTimeDateTimeA DateTime containing the value to set for the creation date and time of
path. This value is expressed in local time.
SetCreationTimeUtc(AbsolutePath, DateTime)
Sets the date and time, in Coordinated Universal Time (UTC), that the file was created.
public static void SetCreationTimeUtc(this AbsolutePath path, DateTime creationTimeUtc)
Parameters
pathAbsolutePathThe file for which to set the creation date and time information.
creationTimeUtcDateTimeThe value to set for the creation date and time of
path. This value is expressed in UTC time.
SetLastAccessTime(AbsolutePath, DateTime)
Sets the date and time the specified file was last accessed.
public static void SetLastAccessTime(this AbsolutePath path, DateTime lastAccessTime)
Parameters
pathAbsolutePathThe file for which to set the access date and time information.
lastAccessTimeDateTimeA DateTime containing the value to set for the last access date and time of
path. This value is expressed in local time.
SetLastAccessTimeUtc(AbsolutePath, DateTime)
Sets the date and time, in Coordinated Universal Time (UTC), that the specified file was last accessed.
public static void SetLastAccessTimeUtc(this AbsolutePath path, DateTime lastAccessTimeUtc)
Parameters
pathAbsolutePathThe file for which to set the access date and time information.
lastAccessTimeUtcDateTimeA DateTime containing the value to set for the last access date and time of
path. This value is expressed in UTC time.
SetLastWriteTime(AbsolutePath, DateTime)
Sets the date and time that the specified file was last written to.
public static void SetLastWriteTime(this AbsolutePath path, DateTime lastWriteTime)
Parameters
pathAbsolutePathThe file for which to set the date and time information.
lastWriteTimeDateTimeA DateTime containing the value to set for the last write date and time of
path. This value is expressed in local time.
SetLastWriteTimeUtc(AbsolutePath, DateTime)
Sets the date and time, in Coordinated Universal Time (UTC), that the specified file was last written to.
public static void SetLastWriteTimeUtc(this AbsolutePath path, DateTime lastWriteTimeUtc)
Parameters
pathAbsolutePathThe file for which to set the date and time information.
lastWriteTimeUtcDateTimeA DateTime containing the value to set for the last write date and time of
path. This value is expressed in UTC time.
WriteAllBytes(AbsolutePath, byte[])
Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is truncated and overwritten.
public static void WriteAllBytes(this AbsolutePath path, byte[] bytes)
Parameters
pathAbsolutePathThe file to write to.
bytesbyte[]The bytes to write to the file.
WriteAllLines(AbsolutePath, IEnumerable<string>)
Creates a new file, writes a collection of strings to the file, and then closes the file.
public static void WriteAllLines(this AbsolutePath path, IEnumerable<string> contents)
Parameters
pathAbsolutePathThe file to write to.
contentsIEnumerable<string>The lines to write to the file.
WriteAllLines(AbsolutePath, IEnumerable<string>, Encoding)
Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file.
public static void WriteAllLines(this AbsolutePath path, IEnumerable<string> contents, Encoding encoding)
Parameters
pathAbsolutePathThe file to write to.
contentsIEnumerable<string>The lines to write to the file.
encodingEncodingThe character encoding to use.
WriteAllLines(AbsolutePath, string[])
Creates a new file, write the specified string array to the file, and then closes the file.
public static void WriteAllLines(this AbsolutePath path, string[] contents)
Parameters
pathAbsolutePathThe file to write to.
contentsstring[]The string array to write to the file.
WriteAllLines(AbsolutePath, string[], Encoding)
Creates a new file, writes the specified string array to the file by using the specified encoding, and then closes the file.
public static void WriteAllLines(this AbsolutePath path, string[] contents, Encoding encoding)
Parameters
pathAbsolutePathThe file to write to.
contentsstring[]The string array to write to the file.
encodingEncodingAn Encoding object that represents the character encoding applied to the string array.
WriteAllText(AbsolutePath, string?)
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.
public static void WriteAllText(this AbsolutePath path, string? contents)
Parameters
pathAbsolutePathThe file to write to.
contentsstringThe string to write to the file.
WriteAllText(AbsolutePath, string?, Encoding)
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.
public static void WriteAllText(this AbsolutePath path, string? contents, Encoding encoding)
Parameters
pathAbsolutePathThe file to write to.
contentsstringThe string to write to the file.
encodingEncodingThe character encoding to use.