473,854 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange FileWatch problem

Hello All!
I may have posted this problem before, but it was awhile ago.
I'm working in VS 2003. I have 10 file watch process going. It seems that
I can only about 6or 7 to run at the same time. I made a test program to
isolate the problem from my program. Still same thing
Basicly I have one application creating a file, the other application
running the file watch procces. When a file with a certain extension is
created, then a form opens up. Here some code of the filewatch in all its
glory!

Imports System.IO
Imports System.Configur ation

Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnos tics.DebuggerSt epThrough()Priv ate Sub
InitializeCompo nent()
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(1048, 590)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region
Protected ConnString As String =
ConfigurationSe ttings.AppSetti ngs("ConnString ")
Protected PrintWinfile As String =
ConfigurationSe ttings.AppSetti ngs("PrintWinFi le")
Protected TempFileSetting As String =
ConfigurationSe ttings.AppSetti ngs("TempFileSe tting")
Protected WinnerFile As String =
ConfigurationSe ttings.AppSetti ngs("WinnerFile ")
Public NKWatch As New FileSystemWatch er
Public KWatch As New FileSystemWatch er
Public OffWatch As New FileSystemWatch er
Public OnWatch As New FileSystemWatch er
Public PassWatch As New FileSystemWatch er
Public RunWatch As New FileSystemWatch er
Public FggWatch As New FileSystemWatch er
Public FgnWatch As New FileSystemWatch er
Public IncWatch As New FileSystemWatch er
Public ToWatch As New FileSystemWatch er
Public PuntOffWatch1 As New FileSystemWatch er
Public PuntDefWatch As New FileSystemWatch er
Public RollMsg As New FileSystemWatch er

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Fires of Fille watcher
AddHandler NKWatch.Created , AddressOf NKWatch_Created

NKWatch.Path = "C:\PlayC\Q tr2"

NKWatch.Filter = "*.Nkc"
NKWatch.Include Subdirectories = False
NKWatch.EnableR aisingEvents = True
NKWatch.BeginIn it()
AddHandler KWatch.Created, AddressOf KWatch_Created
KWatch.Path = "C:\PlayC\Q tr2"
KWatch.Filter = "*.Kic"
KWatch.IncludeS ubdirectories = False
KWatch.EnableRa isingEvents = True
KWatch.BeginIni t()

AddHandler OffWatch.Create d, AddressOf OffWatch_Create d
Try

OffWatch.Path = "\\Localserver\ PlayC\"
OffWatch.Filter = "*.off"
OffWatch.Includ eSubdirectories = False
OffWatch.Enable RaisingEvents = True
Catch ERR As Exception
MessageBox.Show (ERR.Message)
End Try
AddHandler OnWatch.Created , AddressOf OnWatch_Created
OnWatch.Path = "\\Localserver\ PlayC\"
OnWatch.Filter = "*.on"
OnWatch.Include Subdirectories = False
OnWatch.EnableR aisingEvents = True
AddHandler PassWatch.Creat ed, AddressOf PassWatch_Creat ed
PassWatch.Path = "\\Localserver\ PlayC\"
PassWatch.Filte r = "*.pas"
PassWatch.Inclu deSubdirectorie s = False
PassWatch.Enabl eRaisingEvents = True
AddHandler RollMsg.Created , AddressOf RollMsg_Created
RollMsg.Path = "\\Localserver\ PlayC\"
RollMsg.Filter = "*.rb"
RollMsg.Include Subdirectories = False
RollMsg.EnableR aisingEvents = True

AddHandler RunWatch.Create d, AddressOf RunWatch_Create d
RunWatch.Path = "\\Localserver\ PlayC\"
RunWatch.Filter = "*.run"
RunWatch.Includ eSubdirectories = False
RunWatch.Enable RaisingEvents = True

AddHandler PuntOffWatch1.C reated, AddressOf PuntOffWatch1_C reated
PuntOffWatch1.P ath = "\\Localserver\ PlayC\"
PuntOffWatch1.F ilter = "*.pow"
PuntOffWatch1.I ncludeSubdirect ories = False
PuntOffWatch1.E nableRaisingEve nts = True

AddHandler ToWatch.Created , AddressOf ToWatch_Created
ToWatch.Path = "\\Localserver\ PlayC\"
ToWatch.Filter = "*.to"
ToWatch.EnableR aisingEvents = True
ToWatch.Include Subdirectories = False

AddHandler FggWatch.Create d, AddressOf FggWatch_Create d
FggWatch.Path = "\\Localserver\ PlayC\"
FggWatch.Filter = "*.fgg"
FggWatch.Includ eSubdirectories = False
FggWatch.Enable RaisingEvents = True
AddHandler FgnWatch.Create d, AddressOf FgnWatch_Create d
FgnWatch.Path = "\\Localserver\ PlayC\"
FgnWatch.Filter = "*.fgn"
FgnWatch.Includ eSubdirectories = False
FgnWatch.Enable RaisingEvents = True

AddHandler IncWatch.Create d, AddressOf IncWatch_Create d
IncWatch.Path = "\\Localserver\ PlayC\"
IncWatch.Filter = "*.inw"
IncWatch.Includ eSubdirectories = False
IncWatch.Enable RaisingEvents = True
AddHandler PuntDefWatch.Cr eated, AddressOf PuntDefWatch_Cr eated
PuntDefWatch.Pa th = "\\Localserver\ PlayC\"
PuntDefWatch.Fi lter = "*.pdw"
PuntDefWatch.In cludeSubdirecto ries = False
PuntDefWatch.En ableRaisingEven ts = True
End Sub
Private Sub NKWatch_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run (Form2)
End Sub
Private Sub KWatch_Created( ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run (Form2)
End Sub
Private Sub OffWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmOne As Form2
Dim frmOff As New Form2
frmOff.ShowDial og()
End Sub
Private Sub OnWatch_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmOn As New Form2
frmOn.ShowDialo g()
End Sub
Private Sub PassWatch_Creat ed(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmPass As New Form2
frmPass.ShowDia log()
End Sub
Private Sub RunWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmRun As New Form2
frmRun.ShowDial og()
End Sub
Private Sub FggWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmFgg As New Form2
frmFgg.ShowDial og()
End Sub
Private Sub FgnWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmFgn As New Form2
frmFgn.ShowDial og()
End Sub
Private Sub IncWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmInc As New Form2
frmInc.ShowDial og()
End Sub
Private Sub ToWatch_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmTo As New Form2
frmTo.ShowDialo g()
End Sub
Private Sub PuntOffWatch1_C reated(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmPO As New Form2
frmPO.ShowDialo g()
End Sub
Private Sub PuntDefWatch_Cr eated(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmPd As New Form2
frmPd.ShowDialo g()
End Sub
Private Sub RollMsg_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmRoll As New Form2
frmRoll.ShowDia log()
End Sub
End Class

You can pretty much paste all this code. A smaple of what I'm doing to
creat the file is...

Private Sub FileCreatBtn
Dim TimeStamp As String = Guid.NewGuid.Ge tHashCode
'Dim TempFile As String = ("C:\PlayC\Qtr2 \" & TimeStamp.ToStr ing())
Dim ext As String = ".pas"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(File Name, FileMode.Create )
fs.Close()
File.Delete(Fil eName)
End Sub

Sorry for the long code. If I can only get all the of the watches to work
at the same time. They were all working at one time, but after adding more
stuff to the program, it stopped. Not sure exactly when it happend. I'm also
using a diffrent extension for each watch, so the above is .pas, another
maybe .tyu. That way I can open up a diffrent form based on the extension.

TIA!!!

Rudy
May 5 '07 #1
3 1653
I have never worked with the Filewatcher.. but perhaps this will help you.
http://www.codeproject.com/cs/files/C__FileWatcher.asp

"Rudy" <Ru**@discussio ns.microsoft.co mwrote in message
news:B1******** *************** ***********@mic rosoft.com...
Hello All!
I may have posted this problem before, but it was awhile ago.
I'm working in VS 2003. I have 10 file watch process going. It seems
that
I can only about 6or 7 to run at the same time. I made a test program to
isolate the problem from my program. Still same thing
Basicly I have one application creating a file, the other application
running the file watch procces. When a file with a certain extension is
created, then a form opens up. Here some code of the filewatch in all its
glory!

Imports System.IO
Imports System.Configur ation

Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnos tics.DebuggerSt epThrough()Priv ate Sub
InitializeCompo nent()
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(1048, 590)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region
Protected ConnString As String =
ConfigurationSe ttings.AppSetti ngs("ConnString ")
Protected PrintWinfile As String =
ConfigurationSe ttings.AppSetti ngs("PrintWinFi le")
Protected TempFileSetting As String =
ConfigurationSe ttings.AppSetti ngs("TempFileSe tting")
Protected WinnerFile As String =
ConfigurationSe ttings.AppSetti ngs("WinnerFile ")
Public NKWatch As New FileSystemWatch er
Public KWatch As New FileSystemWatch er
Public OffWatch As New FileSystemWatch er
Public OnWatch As New FileSystemWatch er
Public PassWatch As New FileSystemWatch er
Public RunWatch As New FileSystemWatch er
Public FggWatch As New FileSystemWatch er
Public FgnWatch As New FileSystemWatch er
Public IncWatch As New FileSystemWatch er
Public ToWatch As New FileSystemWatch er
Public PuntOffWatch1 As New FileSystemWatch er
Public PuntDefWatch As New FileSystemWatch er
Public RollMsg As New FileSystemWatch er

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Fires of Fille watcher
AddHandler NKWatch.Created , AddressOf NKWatch_Created

NKWatch.Path = "C:\PlayC\Q tr2"

NKWatch.Filter = "*.Nkc"
NKWatch.Include Subdirectories = False
NKWatch.EnableR aisingEvents = True
NKWatch.BeginIn it()
AddHandler KWatch.Created, AddressOf KWatch_Created
KWatch.Path = "C:\PlayC\Q tr2"
KWatch.Filter = "*.Kic"
KWatch.IncludeS ubdirectories = False
KWatch.EnableRa isingEvents = True
KWatch.BeginIni t()

AddHandler OffWatch.Create d, AddressOf OffWatch_Create d
Try

OffWatch.Path = "\\Localserver\ PlayC\"
OffWatch.Filter = "*.off"
OffWatch.Includ eSubdirectories = False
OffWatch.Enable RaisingEvents = True
Catch ERR As Exception
MessageBox.Show (ERR.Message)
End Try
AddHandler OnWatch.Created , AddressOf OnWatch_Created
OnWatch.Path = "\\Localserver\ PlayC\"
OnWatch.Filter = "*.on"
OnWatch.Include Subdirectories = False
OnWatch.EnableR aisingEvents = True
AddHandler PassWatch.Creat ed, AddressOf PassWatch_Creat ed
PassWatch.Path = "\\Localserver\ PlayC\"
PassWatch.Filte r = "*.pas"
PassWatch.Inclu deSubdirectorie s = False
PassWatch.Enabl eRaisingEvents = True
AddHandler RollMsg.Created , AddressOf RollMsg_Created
RollMsg.Path = "\\Localserver\ PlayC\"
RollMsg.Filter = "*.rb"
RollMsg.Include Subdirectories = False
RollMsg.EnableR aisingEvents = True

AddHandler RunWatch.Create d, AddressOf RunWatch_Create d
RunWatch.Path = "\\Localserver\ PlayC\"
RunWatch.Filter = "*.run"
RunWatch.Includ eSubdirectories = False
RunWatch.Enable RaisingEvents = True

AddHandler PuntOffWatch1.C reated, AddressOf PuntOffWatch1_C reated
PuntOffWatch1.P ath = "\\Localserver\ PlayC\"
PuntOffWatch1.F ilter = "*.pow"
PuntOffWatch1.I ncludeSubdirect ories = False
PuntOffWatch1.E nableRaisingEve nts = True

AddHandler ToWatch.Created , AddressOf ToWatch_Created
ToWatch.Path = "\\Localserver\ PlayC\"
ToWatch.Filter = "*.to"
ToWatch.EnableR aisingEvents = True
ToWatch.Include Subdirectories = False

AddHandler FggWatch.Create d, AddressOf FggWatch_Create d
FggWatch.Path = "\\Localserver\ PlayC\"
FggWatch.Filter = "*.fgg"
FggWatch.Includ eSubdirectories = False
FggWatch.Enable RaisingEvents = True
AddHandler FgnWatch.Create d, AddressOf FgnWatch_Create d
FgnWatch.Path = "\\Localserver\ PlayC\"
FgnWatch.Filter = "*.fgn"
FgnWatch.Includ eSubdirectories = False
FgnWatch.Enable RaisingEvents = True

AddHandler IncWatch.Create d, AddressOf IncWatch_Create d
IncWatch.Path = "\\Localserver\ PlayC\"
IncWatch.Filter = "*.inw"
IncWatch.Includ eSubdirectories = False
IncWatch.Enable RaisingEvents = True
AddHandler PuntDefWatch.Cr eated, AddressOf PuntDefWatch_Cr eated
PuntDefWatch.Pa th = "\\Localserver\ PlayC\"
PuntDefWatch.Fi lter = "*.pdw"
PuntDefWatch.In cludeSubdirecto ries = False
PuntDefWatch.En ableRaisingEven ts = True
End Sub
Private Sub NKWatch_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run (Form2)
End Sub
Private Sub KWatch_Created( ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run (Form2)
End Sub
Private Sub OffWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmOne As Form2
Dim frmOff As New Form2
frmOff.ShowDial og()
End Sub
Private Sub OnWatch_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmOn As New Form2
frmOn.ShowDialo g()
End Sub
Private Sub PassWatch_Creat ed(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmPass As New Form2
frmPass.ShowDia log()
End Sub
Private Sub RunWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmRun As New Form2
frmRun.ShowDial og()
End Sub
Private Sub FggWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmFgg As New Form2
frmFgg.ShowDial og()
End Sub
Private Sub FgnWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmFgn As New Form2
frmFgn.ShowDial og()
End Sub
Private Sub IncWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmInc As New Form2
frmInc.ShowDial og()
End Sub
Private Sub ToWatch_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmTo As New Form2
frmTo.ShowDialo g()
End Sub
Private Sub PuntOffWatch1_C reated(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmPO As New Form2
frmPO.ShowDialo g()
End Sub
Private Sub PuntDefWatch_Cr eated(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmPd As New Form2
frmPd.ShowDialo g()
End Sub
Private Sub RollMsg_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmRoll As New Form2
frmRoll.ShowDia log()
End Sub
End Class

You can pretty much paste all this code. A smaple of what I'm doing to
creat the file is...

Private Sub FileCreatBtn
Dim TimeStamp As String = Guid.NewGuid.Ge tHashCode
'Dim TempFile As String = ("C:\PlayC\Qtr2 \" & TimeStamp.ToStr ing())
Dim ext As String = ".pas"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(File Name, FileMode.Create )
fs.Close()
File.Delete(Fil eName)
End Sub

Sorry for the long code. If I can only get all the of the watches to work
at the same time. They were all working at one time, but after adding
more
stuff to the program, it stopped. Not sure exactly when it happend. I'm
also
using a diffrent extension for each watch, so the above is .pas, another
maybe .tyu. That way I can open up a diffrent form based on the
extension.

TIA!!!

Rudy
May 5 '07 #2
Hmm, I read your post again..
and I guess you're program is working not just like you want it to... so my
link will probably not be of much good :P

"Anders B" <an****@wantno. spamwrote in message
news:ek******** ******@TK2MSFTN GP04.phx.gbl...
>I have never worked with the Filewatcher.. but perhaps this will help you.
http://www.codeproject.com/cs/files/C__FileWatcher.asp

"Rudy" <Ru**@discussio ns.microsoft.co mwrote in message
news:B1******** *************** ***********@mic rosoft.com...
>Hello All!
I may have posted this problem before, but it was awhile ago.
I'm working in VS 2003. I have 10 file watch process going. It seems
that
I can only about 6or 7 to run at the same time. I made a test program to
isolate the problem from my program. Still same thing
Basicly I have one application creating a file, the other application
running the file watch procces. When a file with a certain extension is
created, then a form opens up. Here some code of the filewatch in all its
glory!

Imports System.IO
Imports System.Configur ation

Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnos tics.DebuggerSt epThrough()Priv ate Sub
InitializeComp onent()
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(1048, 590)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region
Protected ConnString As String =
ConfigurationS ettings.AppSett ings("ConnStrin g")
Protected PrintWinfile As String =
ConfigurationS ettings.AppSett ings("PrintWinF ile")
Protected TempFileSetting As String =
ConfigurationS ettings.AppSett ings("TempFileS etting")
Protected WinnerFile As String =
ConfigurationS ettings.AppSett ings("WinnerFil e")
Public NKWatch As New FileSystemWatch er
Public KWatch As New FileSystemWatch er
Public OffWatch As New FileSystemWatch er
Public OnWatch As New FileSystemWatch er
Public PassWatch As New FileSystemWatch er
Public RunWatch As New FileSystemWatch er
Public FggWatch As New FileSystemWatch er
Public FgnWatch As New FileSystemWatch er
Public IncWatch As New FileSystemWatch er
Public ToWatch As New FileSystemWatch er
Public PuntOffWatch1 As New FileSystemWatch er
Public PuntDefWatch As New FileSystemWatch er
Public RollMsg As New FileSystemWatch er

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventAr gs) Handles MyBase.Load
'Fires of Fille watcher
AddHandler NKWatch.Created , AddressOf NKWatch_Created

NKWatch.Path = "C:\PlayC\Q tr2"

NKWatch.Filter = "*.Nkc"
NKWatch.Include Subdirectories = False
NKWatch.EnableR aisingEvents = True
NKWatch.BeginIn it()
AddHandler KWatch.Created, AddressOf KWatch_Created
KWatch.Path = "C:\PlayC\Q tr2"
KWatch.Filter = "*.Kic"
KWatch.IncludeS ubdirectories = False
KWatch.EnableRa isingEvents = True
KWatch.BeginIni t()

AddHandler OffWatch.Create d, AddressOf OffWatch_Create d
Try

OffWatch.Path = "\\Localserver\ PlayC\"
OffWatch.Filter = "*.off"
OffWatch.Includ eSubdirectories = False
OffWatch.Enable RaisingEvents = True
Catch ERR As Exception
MessageBox.Show (ERR.Message)
End Try
AddHandler OnWatch.Created , AddressOf OnWatch_Created
OnWatch.Path = "\\Localserver\ PlayC\"
OnWatch.Filter = "*.on"
OnWatch.Include Subdirectories = False
OnWatch.EnableR aisingEvents = True
AddHandler PassWatch.Creat ed, AddressOf PassWatch_Creat ed
PassWatch.Path = "\\Localserver\ PlayC\"
PassWatch.Filte r = "*.pas"
PassWatch.Inclu deSubdirectorie s = False
PassWatch.Enabl eRaisingEvents = True
AddHandler RollMsg.Created , AddressOf RollMsg_Created
RollMsg.Path = "\\Localserver\ PlayC\"
RollMsg.Filter = "*.rb"
RollMsg.Include Subdirectories = False
RollMsg.EnableR aisingEvents = True

AddHandler RunWatch.Create d, AddressOf RunWatch_Create d
RunWatch.Path = "\\Localserver\ PlayC\"
RunWatch.Filter = "*.run"
RunWatch.Includ eSubdirectories = False
RunWatch.Enable RaisingEvents = True

AddHandler PuntOffWatch1.C reated, AddressOf PuntOffWatch1_C reated
PuntOffWatch1.P ath = "\\Localserver\ PlayC\"
PuntOffWatch1.F ilter = "*.pow"
PuntOffWatch1.I ncludeSubdirect ories = False
PuntOffWatch1.E nableRaisingEve nts = True

AddHandler ToWatch.Created , AddressOf ToWatch_Created
ToWatch.Path = "\\Localserver\ PlayC\"
ToWatch.Filter = "*.to"
ToWatch.EnableR aisingEvents = True
ToWatch.Include Subdirectories = False

AddHandler FggWatch.Create d, AddressOf FggWatch_Create d
FggWatch.Path = "\\Localserver\ PlayC\"
FggWatch.Filter = "*.fgg"
FggWatch.Includ eSubdirectories = False
FggWatch.Enable RaisingEvents = True
AddHandler FgnWatch.Create d, AddressOf FgnWatch_Create d
FgnWatch.Path = "\\Localserver\ PlayC\"
FgnWatch.Filter = "*.fgn"
FgnWatch.Includ eSubdirectories = False
FgnWatch.Enable RaisingEvents = True

AddHandler IncWatch.Create d, AddressOf IncWatch_Create d
IncWatch.Path = "\\Localserver\ PlayC\"
IncWatch.Filter = "*.inw"
IncWatch.Includ eSubdirectories = False
IncWatch.Enable RaisingEvents = True
AddHandler PuntDefWatch.Cr eated, AddressOf PuntDefWatch_Cr eated
PuntDefWatch.Pa th = "\\Localserver\ PlayC\"
PuntDefWatch.Fi lter = "*.pdw"
PuntDefWatch.In cludeSubdirecto ries = False
PuntDefWatch.En ableRaisingEven ts = True
End Sub
Private Sub NKWatch_Created (ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run (Form2)
End Sub
Private Sub KWatch_Created( ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run (Form2)
End Sub
Private Sub OffWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmOne As Form2
Dim frmOff As New Form2
frmOff.ShowDial og()
End Sub
Private Sub OnWatch_Created (ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmOn As New Form2
frmOn.ShowDialo g()
End Sub
Private Sub PassWatch_Creat ed(ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmPass As New Form2
frmPass.ShowDia log()
End Sub
Private Sub RunWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmRun As New Form2
frmRun.ShowDial og()
End Sub
Private Sub FggWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmFgg As New Form2
frmFgg.ShowDial og()
End Sub
Private Sub FgnWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmFgn As New Form2
frmFgn.ShowDial og()
End Sub
Private Sub IncWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmInc As New Form2
frmInc.ShowDial og()
End Sub
Private Sub ToWatch_Created (ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmTo As New Form2
frmTo.ShowDialo g()
End Sub
Private Sub PuntOffWatch1_C reated(ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmPO As New Form2
frmPO.ShowDialo g()
End Sub
Private Sub PuntDefWatch_Cr eated(ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmPd As New Form2
frmPd.ShowDialo g()
End Sub
Private Sub RollMsg_Created (ByVal sender As Object, ByVal e As
System.IO.File SystemEventArgs )
Dim frmRoll As New Form2
frmRoll.ShowDia log()
End Sub
End Class

You can pretty much paste all this code. A smaple of what I'm doing to
creat the file is...

Private Sub FileCreatBtn
Dim TimeStamp As String = Guid.NewGuid.Ge tHashCode
'Dim TempFile As String = ("C:\PlayC\Qtr2 \" &
TimeStamp.ToSt ring())
Dim ext As String = ".pas"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(File Name, FileMode.Create )
fs.Close()
File.Delete(Fil eName)
End Sub

Sorry for the long code. If I can only get all the of the watches to
work
at the same time. They were all working at one time, but after adding
more
stuff to the program, it stopped. Not sure exactly when it happend. I'm
also
using a diffrent extension for each watch, so the above is .pas, another
maybe .tyu. That way I can open up a diffrent form based on the
extension.

TIA!!!

Rudy
May 5 '07 #3
Thanks asyway Anders. I wonder if a case statement woould work?

Rudy

"Anders B" wrote:
Hmm, I read your post again..
and I guess you're program is working not just like you want it to... so my
link will probably not be of much good :P

"Anders B" <an****@wantno. spamwrote in message
news:ek******** ******@TK2MSFTN GP04.phx.gbl...
I have never worked with the Filewatcher.. but perhaps this will help you.
http://www.codeproject.com/cs/files/C__FileWatcher.asp

"Rudy" <Ru**@discussio ns.microsoft.co mwrote in message
news:B1******** *************** ***********@mic rosoft.com...
Hello All!
I may have posted this problem before, but it was awhile ago.
I'm working in VS 2003. I have 10 file watch process going. It seems
that
I can only about 6or 7 to run at the same time. I made a test program to
isolate the problem from my program. Still same thing
Basicly I have one application creating a file, the other application
running the file watch procces. When a file with a certain extension is
created, then a form opens up. Here some code of the filewatch in all its
glory!

Imports System.IO
Imports System.Configur ation

Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnos tics.DebuggerSt epThrough()Priv ate Sub
InitializeCompo nent()
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(1048, 590)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region
Protected ConnString As String =
ConfigurationSe ttings.AppSetti ngs("ConnString ")
Protected PrintWinfile As String =
ConfigurationSe ttings.AppSetti ngs("PrintWinFi le")
Protected TempFileSetting As String =
ConfigurationSe ttings.AppSetti ngs("TempFileSe tting")
Protected WinnerFile As String =
ConfigurationSe ttings.AppSetti ngs("WinnerFile ")
Public NKWatch As New FileSystemWatch er
Public KWatch As New FileSystemWatch er
Public OffWatch As New FileSystemWatch er
Public OnWatch As New FileSystemWatch er
Public PassWatch As New FileSystemWatch er
Public RunWatch As New FileSystemWatch er
Public FggWatch As New FileSystemWatch er
Public FgnWatch As New FileSystemWatch er
Public IncWatch As New FileSystemWatch er
Public ToWatch As New FileSystemWatch er
Public PuntOffWatch1 As New FileSystemWatch er
Public PuntDefWatch As New FileSystemWatch er
Public RollMsg As New FileSystemWatch er

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Fires of Fille watcher
AddHandler NKWatch.Created , AddressOf NKWatch_Created

NKWatch.Path = "C:\PlayC\Q tr2"

NKWatch.Filter = "*.Nkc"
NKWatch.Include Subdirectories = False
NKWatch.EnableR aisingEvents = True
NKWatch.BeginIn it()
AddHandler KWatch.Created, AddressOf KWatch_Created
KWatch.Path = "C:\PlayC\Q tr2"
KWatch.Filter = "*.Kic"
KWatch.IncludeS ubdirectories = False
KWatch.EnableRa isingEvents = True
KWatch.BeginIni t()

AddHandler OffWatch.Create d, AddressOf OffWatch_Create d
Try

OffWatch.Path = "\\Localserver\ PlayC\"
OffWatch.Filter = "*.off"
OffWatch.Includ eSubdirectories = False
OffWatch.Enable RaisingEvents = True
Catch ERR As Exception
MessageBox.Show (ERR.Message)
End Try
AddHandler OnWatch.Created , AddressOf OnWatch_Created
OnWatch.Path = "\\Localserver\ PlayC\"
OnWatch.Filter = "*.on"
OnWatch.Include Subdirectories = False
OnWatch.EnableR aisingEvents = True
AddHandler PassWatch.Creat ed, AddressOf PassWatch_Creat ed
PassWatch.Path = "\\Localserver\ PlayC\"
PassWatch.Filte r = "*.pas"
PassWatch.Inclu deSubdirectorie s = False
PassWatch.Enabl eRaisingEvents = True
AddHandler RollMsg.Created , AddressOf RollMsg_Created
RollMsg.Path = "\\Localserver\ PlayC\"
RollMsg.Filter = "*.rb"
RollMsg.Include Subdirectories = False
RollMsg.EnableR aisingEvents = True

AddHandler RunWatch.Create d, AddressOf RunWatch_Create d
RunWatch.Path = "\\Localserver\ PlayC\"
RunWatch.Filter = "*.run"
RunWatch.Includ eSubdirectories = False
RunWatch.Enable RaisingEvents = True

AddHandler PuntOffWatch1.C reated, AddressOf PuntOffWatch1_C reated
PuntOffWatch1.P ath = "\\Localserver\ PlayC\"
PuntOffWatch1.F ilter = "*.pow"
PuntOffWatch1.I ncludeSubdirect ories = False
PuntOffWatch1.E nableRaisingEve nts = True

AddHandler ToWatch.Created , AddressOf ToWatch_Created
ToWatch.Path = "\\Localserver\ PlayC\"
ToWatch.Filter = "*.to"
ToWatch.EnableR aisingEvents = True
ToWatch.Include Subdirectories = False

AddHandler FggWatch.Create d, AddressOf FggWatch_Create d
FggWatch.Path = "\\Localserver\ PlayC\"
FggWatch.Filter = "*.fgg"
FggWatch.Includ eSubdirectories = False
FggWatch.Enable RaisingEvents = True
AddHandler FgnWatch.Create d, AddressOf FgnWatch_Create d
FgnWatch.Path = "\\Localserver\ PlayC\"
FgnWatch.Filter = "*.fgn"
FgnWatch.Includ eSubdirectories = False
FgnWatch.Enable RaisingEvents = True

AddHandler IncWatch.Create d, AddressOf IncWatch_Create d
IncWatch.Path = "\\Localserver\ PlayC\"
IncWatch.Filter = "*.inw"
IncWatch.Includ eSubdirectories = False
IncWatch.Enable RaisingEvents = True
AddHandler PuntDefWatch.Cr eated, AddressOf PuntDefWatch_Cr eated
PuntDefWatch.Pa th = "\\Localserver\ PlayC\"
PuntDefWatch.Fi lter = "*.pdw"
PuntDefWatch.In cludeSubdirecto ries = False
PuntDefWatch.En ableRaisingEven ts = True
End Sub
Private Sub NKWatch_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run (Form2)
End Sub
Private Sub KWatch_Created( ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run (Form2)
End Sub
Private Sub OffWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmOne As Form2
Dim frmOff As New Form2
frmOff.ShowDial og()
End Sub
Private Sub OnWatch_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmOn As New Form2
frmOn.ShowDialo g()
End Sub
Private Sub PassWatch_Creat ed(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmPass As New Form2
frmPass.ShowDia log()
End Sub
Private Sub RunWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmRun As New Form2
frmRun.ShowDial og()
End Sub
Private Sub FggWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmFgg As New Form2
frmFgg.ShowDial og()
End Sub
Private Sub FgnWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmFgn As New Form2
frmFgn.ShowDial og()
End Sub
Private Sub IncWatch_Create d(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmInc As New Form2
frmInc.ShowDial og()
End Sub
Private Sub ToWatch_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmTo As New Form2
frmTo.ShowDialo g()
End Sub
Private Sub PuntOffWatch1_C reated(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmPO As New Form2
frmPO.ShowDialo g()
End Sub
Private Sub PuntDefWatch_Cr eated(ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmPd As New Form2
frmPd.ShowDialo g()
End Sub
Private Sub RollMsg_Created (ByVal sender As Object, ByVal e As
System.IO.FileS ystemEventArgs)
Dim frmRoll As New Form2
frmRoll.ShowDia log()
End Sub
End Class

You can pretty much paste all this code. A smaple of what I'm doing to
creat the file is...

Private Sub FileCreatBtn
Dim TimeStamp As String = Guid.NewGuid.Ge tHashCode
'Dim TempFile As String = ("C:\PlayC\Qtr2 \" &
TimeStamp.ToStr ing())
Dim ext As String = ".pas"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(File Name, FileMode.Create )
fs.Close()
File.Delete(Fil eName)
End Sub

Sorry for the long code. If I can only get all the of the watches to
work
at the same time. They were all working at one time, but after adding
more
stuff to the program, it stopped. Not sure exactly when it happend. I'm
also
using a diffrent extension for each watch, so the above is .pas, another
maybe .tyu. That way I can open up a diffrent form based on the
extension.

TIA!!!

Rudy

May 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
3755
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's machines. The code opens MS Word through Automation and then opens a particular Word doc. It's still working fine on most machines; but on one or two of them, the user is getting an Automation Error. The code used is as follows: Dim objWord As...
2
1791
by: TB | last post by:
I am seeing a very strange problem as follows... I have a loop where a fair amount of processing is going on and near the top of the loop I access a class that has only static helper functions to perform some calculations. After some number of iterations, randomly, I'll get an uncaught NullValueException error on one of these calls, as if the class name is being treated as an object reference and is null. Here is some psuedo-code to...
1
3772
by: Sam Kong | last post by:
Hello! Recently I had a strange problem with Visual C# 2005 beta 1. When I ran(F5 key) a program, <#if DEBUG> statement was not working. It ran as RELEASE mode. So I had to manually define DEBUG to make #if DEBUG work. When I first started the project, this problem didn't exist. The problem started to exist in the middle of doing the project. Today, I decided to figure out what went wrong.
8
6722
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and contains a few controls anchored to the sides of the form. "frmChild" inherits from "frmBase"... and the controls appear on the inherited form as expected. However things start going wrong when I place addition controls on the "frmChild" form. When I...
11
2603
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating temperatures. T = 20 degrees at all times.... The 2D T-array looks like this:
3
2495
by: Rudy | last post by:
Hello all! This is what I want to do, looking the for the best way to do this. I have a text file that gets created and placed in a folder. I would like to have a watch for that file when it pops in that folder. But I would alway like to have the watch active. I don't want it at Form Load, and I can't have a button get clicked. I just would like to have when ever that file gets put in that folder, it performs my next step. I'll be...
0
1172
by: Rudy | last post by:
Hello all! I am having problem wih filewatch, I think. Basicly I have a trigger that creates a file. Filewatch looks for a modified date on the file, than when it see's it, it should pop up a message box. The problem it pop's up 3 or 4 message boxes. I just need it once.Here some code from app 1 that will execute the store procedure. Private Sub ON_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
14
1119
by: =?Utf-8?B?UnVkeQ==?= | last post by:
Hello! I posted this problem earlier. I wrote a quick test project, and I still have the same problem. So I'm sure it's something in my code that I'm not writing correctly. Basicly I'm creating a file with abutton click from one application. The other application has a file watch setup, when it see the newly created file, it is prompted to open up a new form. But it locks up atn the very end of opening up the form.
5
2440
by: ioni | last post by:
Good day, fellows! I have a strange problem – at my site there is a flash strip, that loads data dynamically. It works fine (grabs data from the remote server and presents it), however in IE7 and its clones I encounter a strange problem where I can hear clicking sound non-stop (like the page is being reloaded non- stop), whereas the page is not reloading.
0
10682
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10758
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10371
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9513
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5743
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4562
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.