Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim MyFolder As String = "مسار المجلد المصاب"
Dim Dir As IO.DirectoryInfo = New IO.DirectoryInfo(MyFolder)
ChangeFoldersAttributes(Dir)
Catch ex As Exception
MsgBox(ex.Message, 48, "Change Attributes")
End Try
End Sub
Private Sub ChangeFoldersAttributes(ByVal dir As IO.DirectoryInfo)
Try
ChangeFilesAttributes(dir) ' البحث عن ملفات مخفية في المجلد الرئيس
For Each d As IO.DirectoryInfo In dir.GetDirectories
d.Attributes = IO.FileAttributes.Normal ' اظهار المجلد
ChangeFilesAttributes(d) ' البحث عن ملفات مخفية في المجلد المحدد
If d.GetDirectories.Length > 0 Then ' اذا كان المجلد الحالي يحتوي علي مجلدات فرعية سيتم العمل عليها
ChangeFoldersAttributes(d)
End If
Next
Catch ex As Exception
MsgBox(ex.Message, 48, "ChangeFoldersAttributes")
End Try
End Sub
Private Sub ChangeFilesAttributes(ByVal dir As IO.DirectoryInfo)
Try
For Each f As IO.FileInfo In dir.GetFiles
f.Attributes = IO.FileAttributes.Normal
Next
Catch ex As Exception
MsgBox(ex.Message, 48, "ChangeFilesAttributes")
End Try
End Sub