|
-
October 4th, 2018, 10:37 PM
#1
List.Add not set to an instance of an object
Hi, I've got a method where I'm trying to add an object to a list, and Visual Studio debug gives me an error that what I'm trying to add is "not set to an instance of an object". I set my list to be List(Of Object), and also set my variable to a FileSystemWatcher object, but still get the error. Breakpoint just tells me the same thing. Here's my code...if someone has any ideas why I'm getting this error I'm open to suggestions. I've also tried setting everything to string type, but still get the same debug message. Here's my code:
Code:
Public FSWList As List(Of Object)
Public Sub SetupFileWatcher(fswPath As String, fswPlan As String, fswFilter As String, SyncObject As Form)
Dim fsw As FileSystemWatcher = New FileSystemWatcher(fswPath)
If fswPath.Length = 0 Then
Return
End If
fsw.BeginInit()
fsw.SynchronizingObject = SyncObject
fsw.InternalBufferSize = 32768
fsw.IncludeSubdirectories = True
fsw.Filter = fswFilter
fsw.Path = fswPath
fsw.NotifyFilter = NotifyFilters.FileName Or NotifyFilters.CreationTime
AddHandler Me.Created, New FileSystemEventHandler(AddressOf Me.OnCreated)
AddHandler Me.Deleted, New FileSystemEventHandler(AddressOf Me.OnDeleted)
fsw.EnableRaisingEvents = True
fsw.EndInit()
'this is the line that is giving me the error
FSWList.Add(fsw)
End Sub
Thanks for any ideas.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|