ShlwApiPathRenameExtension Method

Note: This API is now obsolete.
Replaces the extension of a file name with a new extension.

If the file name does not contain an extension, the extension will be attached to the end of the string.

Note: Misuse of this function can lead to a buffer overrun. We recommend the use of the safer PathCchRenameExtension(StringBuilder, UInt32, String) function in its place.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("ShlwApi.dll", CharSet = CharSet.Auto, BestFitMapping = false, 
	ThrowOnUnmappableChar = true, SetLastError = true)]
[ObsoleteAttribute("Misuse of this function can lead to a buffer overrun. We recommend the use of the safer NativeMethods.PathCchRenameExtension function in its place.", 
	false)]
public static bool PathRenameExtension(
	StringBuilder path,
	string ext
)

Parameters

path  StringBuilder
Pointer to a null-terminated string of length MAX_PATH in which to replace the extension.
ext  String
Pointer to a character buffer that contains a '.' character followed by the new extension.

Return Value

Boolean
Returns if successful, or if the new path and extension would exceed MAX_PATH characters.

Remarks

See Also