''' <summary>
''' Searches a string using a Microsoft MS-DOS wildcard match type.
''' </summary>
''' <param name="pszFile">A pointer to a null-terminated string of maximum length MAX_PATH that contains the path to be searched.</param>
''' <param name="pszSpec">A pointer to a null-terminated string of maximum length MAX_PATH that contains the file type for which to search. For example, to test whether pszFile is a .doc file, pszSpec should be set to "*.doc".</param>
''' <returns>Returns TRUE if the string matches, or FALSE otherwise.</returns>
<DllImport("shlwapi.dll", EntryPoint:="PathMatchSpecW", SetLastError:=True, CharSet:=CharSet.Unicode)> _
Public Function PathMatchSpec(<MarshalAs(UnmanagedType.LPTStr)>pszFile As String, _
<MarshalAs(UnmanagedType.LPTStr)>pszSpec As String) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
VB Signature:
Private Declare Auto Function PathMatchSpec Lib "shlwapi" _
(ByVal pszFileParam As String, _
ByVal pszSpec As String) As Boolean
User-Defined Types:
None.
Notes:
None.
Tips & Tricks:
Please add some!
Sample Code:
C# Example
if(PathMatchSpec("C:\\test.txt", "*.txt"))
{
// This is text file.
}
VB.NET Example
Private Function MatchSpec(ByVal sFile As String, ByVal sSpec As String) As Boolean
Return PathMatchSpec(sFile, sSpec)
End Function
VB Example
Private Function MatchSpec(ByVal sFile As String, ByVal sSpec As String) As Boolean
MatchSpec = PathMatchSpec(sFile, sSpec)
End Function
Alternative Managed API:
Do you know one? Please contribute it!
PathMatchSpec - Searches a string using a Microsoft MS-DOS wildcard match type.
2/8/2012 5:54:17 AM - johnbell149@gmail.com-202.74.138.1
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).