-3
フォームが読み込まれたときに、ディレクトリ内にいくつのファイルがあるかを数えます。 winformアプリケーションの実行中にn秒ごとにそのラベルを更新したい。私はこれをacheiveするかどうかはわかりません、ここにファイルをカウントする負荷に私のです:winformでn秒ごとにラベルコントロールを更新するには?
Public Function getUserCountsTotal() As Integer
Dim di As New DirectoryInfo("C:\myDirectory")
Dim Users As FileInfo() = di.GetFiles().OrderByDescending(Function(fi) fi.LastWriteTime).ToArray()
Dim user As FileInfo
'list the names of all files in the specified directory
For Each user In Users
ComboBox1.Items.Add(Path.GetFileNameWithoutExtension(user.Name) & "- " & user.LastWriteTime)
Next
getUserCountsTotal = ComboBox1.Items.Count + 1
End Function
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
statusPanel.Text = ""
statusPanel.Text = "Logged in as " & getYourUserName() & " - " & "[ " & getUserCountsTotal() & " ] "
End Sub
[Timer?](https://msdn.microsoft.com/en-us/library/system)を使用します。 windows.forms.timer(v = vs.110).aspx) –
古いアイテムを削除せずに新しいアイテムを 'ComboBox'に追加し続けているので、番号は続けられます。あなたは[** 'ComboBox.Items.Clear()' **](https://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.objectcollection.clear(v = vs.110).aspx)を使用して新しいアイテムを追加します。 –