PathRemoveExtension (shlwapi)
Last changed: anonymous

.
Summary
PathRemoveExtension - Removes the file name extension from a path, if one is present.

C# Signature:

/// <summary>
/// Removes the file name extension from a path, if one is present.
/// </summary>
/// <param name="pszFile">A pointer to a null-terminated string of length MAX_PATH from which to remove the extension.</param>
[DllImport("shlwapi.dll", EntryPoint = "PathRemoveExtensionW",  SetLastError = True, CharSet= CharSet.Unicode)]
static extern void PathRemoveExtension([MarshalAs(UnmanagedType.LPTStr)]System.Text.StringBuilder pszFile);

VB.NET Extension

''' <summary>
''' Removes the file name extension from a path, if one is present.
''' </summary>
''' <param name="pszFile">A pointer to a null-terminated string of length MAX_PATH from which to remove the extension.</param>
<DllImport("shlwapi.dll", EntryPoint:="PathRemoveExtensionW",  SetLastError:=True, CharSet:=CharSet.Unicode)> _
Public Sub PathRemoveExtension(<MarshalAs(UnmanagedType.LPTStr)>pszFile As System.Text.StringBuilder)
End Sub

VB Signature:

Public Declare Sub PathRemoveExtension Lib "shlwapi" Alias "PathRemoveExtensionA" _
        (ByVal pszPath As String)

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Dim strFile As New system.Text.StringBuilder(255)
strFile.Append("c:\abc\def\words.doc")
Win32.API.Shlwapi.PathRemoveExtension(strFile)
System.Diagnostics.Debug.WriteLine(strFile.ToString())

Documentation