tælle filer
Det kode her---
Imports System
Imports System.Threading
Imports System.IO
Imports System.Windows.Forms.Control
Public Class Form1
Private thread1 As Thread
Shared counter_1 As Int32
Shared counter_2 As Int32
Shared list As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim value As Boolean
value = False 'Control.CheckForIllegalCrossThreadCalls
Control.CheckForIllegalCrossThreadCalls = value
End Sub
Private Sub sub_1(ByVal path)
Dim item, item2 As String
If path = "" Then path = "c:\windows"
Try
For Each item In Directory.GetDirectories(path)
counter_1 = counter_1 + 1
'Console.WriteLine(item)
Label1.Text = item
For Each item2 In Directory.GetFiles(item)
counter_2 = counter_2 + 1
Label2.Text = item2
count()
Next
sub_1(item)
count()
Next
Catch ex As Exception
TextBox1.AppendText(path & "[" & ex.Message & "]")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
thread1 = New Thread(AddressOf sub_1)
thread1.Start()
End Sub
Function count()
Label3.Text = counter_1
Label4.Text = counter_2
Return True
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If thread1.IsAlive Then thread1.Abort()
End Sub
End Class
---
Tæller MEGET langsomt i forhold til en dir /s i en prompt....
Hvorfor?