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.
Namespace: DevCase.Win32.NativeMethodsAssembly: 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
)
<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 Shared Function PathRenameExtension (
path As StringBuilder,
ext As String
) As Boolean
Dim path As StringBuilder
Dim ext As String
Dim returnValue As Boolean
returnValue = ShlwApi.PathRenameExtension(path,
ext)
public:
[DllImportAttribute(L"ShlwApi.dll", CharSet = CharSet::Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
[ObsoleteAttribute(L"Misuse of this function can lead to a buffer overrun. We recommend the use of the safer NativeMethods.PathCchRenameExtension function in its place.",
false)]
static bool PathRenameExtension(
StringBuilder^ path,
String^ ext
)
[<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)>]
static member PathRenameExtension :
path : StringBuilder *
ext : string -> bool
No code example is currently available or this language may not be supported.
- 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.
Boolean
Returns
if successful, or
if the new path and extension would exceed MAX_PATH characters.