NAnt SDK Documentation - v0.92

PathFunctions.ChangeExtension Method 

Changes the extension of the path string.

[Visual Basic]
<Function(Name:="change-extension")>
Public Shared Function ChangeExtension( _
   ByVal path As String, _
   ByVal extension As String _
) As String
[C#]
[Function(Name="change-extension")]
public static string ChangeExtension(
   string path,
   string extension
);

Parameters

path
The path information to modify. The path cannot contain any of the characters defined in InvalidPathCharsInvalidPathChars.
extension
The new extension (with a leading period). Specify a null reference to remove an existing extension from path.

Return Value

A string containing the modified path information.

On Windows-based desktop platforms, if path is an empty String, the path information is returned unmodified. If path has no extension, the returned path String contains extension appended to the end of path.

Remarks

For more information see the Path documentation.

Exceptions

Exception Type Condition
ArgumentException path contains one or more invalid characters.

See Also

PathFunctions Class | NAnt.Core.Functions Namespace