Public Shared Function FileCount(PathName As String) As Long Try Dim FSO As New FileSystemObject Dim fld As Folder If FSO.FolderExists(PathName) Then fld = FSO.GetFolder(PathName) FileCount = fld.Files.Count End If Return FileCount Catch ex As DirectoryNotFoundException End Try End Function 'Calculate File Count Public Shared Sub StartNewScan(ByVal FilePath As String) Dim Allfile As String = "*.*" Dim FFcount As Long Dim MyFolderSize As Long Dim FullPath As String Using fse As New FindFiles.FileSystemEnumerator(FilePath, Allfile, True) Dim ien As IEnumerator(Of FileInfo) = fse.Matches().GetEnumerator() ien.Dispose() For Each fi As FileInfo In fse.Matches() FFcount += CStr(FileCount(fi.DirectoryName)).Length Form1.Label3.Text = CStr( "File Count:" & FFcount) MyFolderSize += fi.Length FullPath = fi.FullName Form1.Label4.Text = "File Path:" & FullPath Next End Using End Sub
Dim StartSharedSub as new threading.thread(addressof Startnewscan) startsharedsub.start()
Invoke
BeginInvoke
System.Windows.Threading.Dispatcher
System.Windows.Forms.Control
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)