By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,640 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,640 IT Pros & Developers. It's quick & easy.

Array using Filesystemwatcher don't run

P: 1
I wrote this code, but it don't work:

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer = 0
  2. Dim drives() As String
  3. drives = GetListofDrives()
  4. or Each sdrives In drives
  5. i += 1
  6. Next
  7. Dim a(i) As FileSystemWatcher
  8. i = 0
  9. For Each drive As IO.DriveInfo In IO.DriveInfo.GetDrives
  10. Dim itemText As String = drive.Name
  11. Dim ltr As String = drive.Name
  12. Dim Type As String
  13. If drive.IsReady AndAlso drive.VolumeLabel <> "" Then
  14. itemText = drive.VolumeLabel
  15. Else
  16. Select Case drive.DriveType
  17. Case IO.DriveType.Fixed : itemText = "Local Disk"
  18. Case IO.DriveType.CDRom : itemText = "CD-ROM"
  19. Case IO.DriveType.Network : itemText = "Network Drive"
  20. Case IO.DriveType.Removable : itemText = "Removable Disk"
  21. Case IO.DriveType.Unknown : itemText = "Unknown"
  22. End Select
  23. End If
  24. Select Case drive.DriveType
  25. Case IO.DriveType.Fixed : Type = "Local Disk"
  26. Case IO.DriveType.CDRom : Type = "CD-ROM"
  27. Case IO.DriveType.Network : Type = "Network Drive"
  28. Case IO.DriveType.Removable : Type = "Removable Disk"
  29. Case IO.DriveType.Unknown : Type = "Unknown"
  30. End Select
  31. If Type = "CD-ROM" Then
  32. Else
  33. a(i) = New FileSystemWatcher
  34. a(i).Path = ltr
  35. AddHandler a(i).Changed, AddressOf scan
  36. a(i).EnableRaisingEvents = True
  37. i += 1
  38. End If
  39. Next
Feb 17 '13 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,382
Please define what doesn't work means. Are you getting error codes? What are they? Are you seeing undefined behavior? What is it? What is the correct behavior?
Feb 17 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.