Method WithExtension
WithExtension(string?, PathOptions)
Changes the current extension of the file name to a new extension.
Declaration
IFilePath WithExtension(string? extension, PathOptions options = PathOptions.NoUnfriendlyNames)
Parameters
| Type | Name | Description |
|---|---|---|
| string | extension | The new 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 |
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".