Private Function IsSystemFolder(folderName As String) As Boolean
If d.Length < 4 Then Return False
' root directory reports as hidden and system
Dim di As New IO.DirectoryInfo(d)
If (di.Attributes And IO.FileAttributes.System) <> 0 Then Return True
Return False
End Function
If we are interested in System Folders, we may also need to know if it is a hidden folder
Private Function IsHiddenFolder(folderName As String) As Boolean
If d.Length < 4 Then Return False
' root directory reports as hidden and system
Dim di As New IO.DirectoryInfo(d)
If (di.Attributes And IO.FileAttributes.Hidden) <> 0 Then Return True
Return False
End Function
When identifying System and Hidden Folders, we may wish to detect certain strings in the folder path because they could indicate the folder contents should not be edited.
Private Function IsSimilarToSystem(d As String) As Boolean
If d.Length < 4 Then Return False ' root directory reports as hidden and system
If d.Contains("\winsxs\", StringComparison.CurrentCultureIgnoreCase) Then Return True
If d.Contains("$"c) OrElse d.Contains("~"c) Then Return True
Dim di As New IO.DirectoryInfo(d)
If (di.Attributes And IO.FileAttributes.System) <> 0 Then Return True
If (di.Attributes And IO.FileAttributes.Hidden) <> 0 Then Return True
Return False
End Function
DigitalDan.co.uk