Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. Public Class Form1
  2. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3. TextBox1.Clear()
  4. Timer1.Start()
  5. FolderBrowserDialog1.ShowDialog()
  6. End Sub
  7. Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  8. If TextBox1.Text$ = vbNullString Then
  9. TextBox1.Text$ = FolderBrowserDialog1.SelectedPath
  10. Else
  11. Timer1.Stop()
  12. End If
  13. End Sub
  14. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  15. Dim f As Integer = 0
  16. Dim fo As Integer = 0
  17. Dim files As Object = My.Computer.FileSystem.GetFiles(TextBox1.Text$)
  18. Dim folders As Object = My.Computer.FileSystem.GetDirectories(TextBox1.Text$)
  19. For Each file In files
  20. f += 1
  21. Next
  22. For Each folder In folders
  23. fo += 1
  24. Next
  25. If f > 0 And fo = 0 Then
  26. MsgBox("There are " & f & " file(s) on this directory", MsgBoxStyle.Information)
  27. ElseIf f = 0 And fo > 0 Then
  28. MsgBox("There are " & fo & " folder(s) on this directory", MsgBoxStyle.Information)
  29. ElseIf f > 0 And fo > 0 Then
  30. MsgBox("There are " & f & " file(s) and " & fo & " folder(s) on this directory", MsgBoxStyle.Information)
  31. ElseIf f = 0 And fo = 0 Then
  32. MsgBox("There are no files/folders on this directory", MsgBoxStyle.Information)
  33. End If
  34. End Sub
  35. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement