logo  VB.Net - Is a System Folder
This Chapter
Copy Delete ...
Is System File
Files in Folder
Special Folders
Chapters
Home Page
Colours, RGB
Computer Specifications
Dates&Times
Disk Drives
Files
Folders
GPS and OS Ref
VB.Net Forms
Image Files
If & Select
List/Array
Mathematics
NuGet
Sound
String Functions
Sun and Moon
User Controls
Validation
DigitalDan Sites
My Other Sites
Contact Site

Note
Some pages
may contain
inaccuracies
Hits=5
A system file should have the System Attribute flag set. This can be detected using the following function
 

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