Public
Class
TestovaciForm
Private
Sub
SpustitVyhledavani()
Dim
T
As
New
SeznamSouboru
T.ProhledejVybranyAdresar(
"C:\Test"
)
End
Sub
End
Class
Public
Class
SeznamSouboru
Private
_FileItems
As
Integer
Public
Property
FileItems()
As
Integer
Get
Return
_FileItems
End
Get
Set
(
ByVal
value
As
Integer
)
_FileItems = value
End
Set
End
Property
Private
_Message
As
String
Public
Property
Message()
As
String
Get
Return
_Message
End
Get
Set
(
ByVal
value
As
String
)
_Message = value
End
Set
End
Property
Private
_PracujiSeSouborem
As
String
Public
Property
PracujiSeSouborem()
As
String
Get
Return
_PracujiSeSouborem
End
Get
Set
(
ByVal
value
As
String
)
_PracujiSeSouborem = value
End
Set
End
Property
Public
Sub
ProhledejVybranyAdresar(
ByVal
SourcePath
As
String
)
Dim
SourceDir
As
DirectoryInfo =
New
DirectoryInfo(SourcePath)
_Message =
"Provádím načtení informací o souborech ve vybrané složce a podsložkách."
If
SourceDir.Exists
Then
Dim
ChildFile
As
FileInfo
For
Each
ChildFile
In
SourceDir.GetFiles()
Try
_PracujiSeSouborem = ChildFile.FullName
_FileItems = _FileItems + 1
AddRow(_FileItems, ChildFile.Name, ChildFile.DirectoryName, ChildFile.Length, ChildFile.CreationTime, GetMD5Hash(ChildFile.FullName))
Catch
Ex
As
System.UnauthorizedAccessException
End
Try
Next
Dim
SubDir
As
DirectoryInfo
For
Each
SubDir
In
SourceDir.GetDirectories()
ProhledejVybranyAdresar(SubDir.FullName)
Next
Else
Throw
New
DirectoryNotFoundException(
"Zdrojovy adresar neexistuje: "
+ SourceDir.FullName)
End
If
Try
Catch
e
As
System.IO.IOException
MessageBox.Show(e.Message())
End
Try
End
Sub
End
Class