KernelBasePathCchRenameExtension Method

Replaces a file name's extension at the end of a path string with a new extension.

If the path string does not end with an extension, the new extension is added.

This function differs from PathRenameExtension(StringBuilder, String) in that it accepts paths with "\", "\?" and "\?\UNC" prefixes.

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("KernelBase.dll", CharSet = CharSet.Auto, BestFitMapping = false, 
	ThrowOnUnmappableChar = true)]
public static HResult PathCchRenameExtension(
	StringBuilder buffer,
	uint bufferSize,
	string ext
)

Parameters

buffer  StringBuilder
A pointer to the path string.

When this function returns successfully, this value points to the same string, but with the renamed or added extension.

bufferSize  UInt32
The size of the buffer pointed to by buffer, in characters.
ext  String
A pointer to the new extension string.

The leading '.' character is optional. In the case of an empty string (""), any existing extension in the path string is removed.

Return Value

HResult
If this function succeeds, it returns S_OK. Otherwise, it returns an HResult error code.

Remarks

See Also