Here is a pice of the code
Private m_WatchDirectory As String
Private WithEvents m_FileSystemWatcher As FileSystemWatcher
Dim log As New Log
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
lstFiles.Items.Add(Now.ToString() & " Starting")
readReg()
log.lstFiles.Items.Add(Now.ToString() & " Init " & LookPath)
log.lstFiles.Items.Add(Now.ToString() & " Init " & ToPath)
' Get the path to the directory we will watch.
m_WatchDirectory = LookPath 'Application.StartupPath
' m_WatchDirectory = m_WatchDirectory.Substring(0,
m_WatchDirectory.LastIndexOf("\"))
'm_WatchDirectory &= LookPath '"\Files"
' Make the FileSystemWatcher.
m_FileSystemWatcher = New FileSystemWatcher(m_WatchDirectory, "*.*") '
"*.txt")
m_FileSystemWatcher.NotifyFilter = 0
m_FileSystemWatcher.NotifyFilter = m_FileSystemWatcher.NotifyFilter Or
NotifyFilters.FileName
m_FileSystemWatcher.EnableRaisingEvents = True
m_FileSystemWatcher.IncludeSubdirectories = alldirs
' Process any files that already exist.
MsgBox(m_WatchDirectory)
ProcessExistingFiles(m_WatchDirectory)
End Sub
Private Sub ProcessExistingFiles(ByVal directory_name As String)
Dim dir_info As New DirectoryInfo(directory_name)
Dim file_infos As FileInfo() = dir_info.GetFiles()
For Each fi As FileInfo In file_infos
ProcessFile(fi.FullName, fi.Name)
Next fi
End Sub
Private Sub ProcessFile(ByVal file_name As String, ByVal shName As String)
log.lstFiles.Items.Add(Now.ToString() & " Processed " & file_name)
If shName = "\Thumbs.db" Then ' = LCase(file_name) Then
Exit Sub
End If
MsgBox(file_name & " " & ToPath & "\" & shName)
FileCopy(file_name, ToPath & "\" & shName)
Kill(file_name)
End Sub
I also have the following in a module file
Public LookPath, ToPath As String
Public AllDirs As Boolean
Petter L.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uR**************@TK2MSFTNGP15.phx.gbl...
Petter,
A nullreference is almost forever a non instanced object.
However the rest probably nobody can see without a little piece of code.
I hope this starts helps?
Cor