JumpyNET
Centurion
- Joined
- Apr 4, 2005
- Messages
- 196
What is the quickest way (by means of processor time) to find out if a folder has subfolders?
If System.IO.Directory.GetDirectories("c:\\test").Length > 0 Then
'has sub folders
End If
public sealed class Shlwapi
{
/*
BOOL PathIsDirectoryEmpty(
LPCTSTR pszPath
);
*/
[DllImport("shlwapi.dll",CharSet=CharSet.Auto,SetLastError=true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PathIsDirectoryEmpty(
[In,MarshalAs(UnmanagedType.LPTStr)] string pszPath
);
}
Public NotInheritable Class ShlWapi
'BOOL PathIsDirectoryEmpty(
' LPCTSTR pszPath
' );
<DllImport("shlwapi.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function PathIsDirectoryEmpty( _
<InAttribute(), MarshalAs(UnmanagedType.LPTStr)> ByVal pszPath As String _
) _
As <MarshalAs(UnmanagedType.Bool)> Boolean
' leave body emtpy
End Function
' or
Declare Auto Function PathIsDirectoryEmpty Lib "shlwapi.dll" _
(<InAttribute(), MarshalAs(UnmanagedType.LPTStr)> ByVal pszPath As String) _
As <MarshalAs(UnmanagedType.Bool)> Boolean
End Class
Wraith said:Visual Basic:Declare Auto Function PathIsDirectoryEmpty Lib "shlwapi.dll" _ (<InAttribute(), MarshalAs(UnmanagedType.LPTStr)> ByVal pszPath As String) _ As <MarshalAs(UnmanagedType.Bool)> Boolean