Method IFilePath.WithExtension
IFilePath.WithExtension(string?, PathOptions)
Changes the last extension of the file name to a new single extension.
Declaration
IFilePath IFilePath.WithExtension(string? extension, PathOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| string | extension | The new single extension that should be applied to the file. Must either be null/empty or start with a dot '.' character and
contain no additional dots (e.g. |
| PathOptions | options | The options to apply when parsing the new file name. The rest of the path is not reparsed. |
Returns
| Type | Description |
|---|---|
| IFilePath |
Implements
Remarks
Only the last extension of the file name is replaced, preserving any previous extensions before it, e.g. "archive.tar.gz" with extension
".zip" becomes "archive.tar.zip". If the file name has multiple extensions and the new extension is null/empty, only the last extension is
removed, e.g. "archive.tar.gz" becomes "archive.tar".