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

Strange FileWatch problem

P: n/a
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.Configuration

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.
InitializeComponent()

'Add any initialization after the InitializeComponent() 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.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'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.Diagnostics.DebuggerStepThrough()Private Sub
InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = 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 =
ConfigurationSettings.AppSettings("ConnString")
Protected PrintWinfile As String =
ConfigurationSettings.AppSettings("PrintWinFile")
Protected TempFileSetting As String =
ConfigurationSettings.AppSettings("TempFileSetting ")
Protected WinnerFile As String =
ConfigurationSettings.AppSettings("WinnerFile")
Public NKWatch As New FileSystemWatcher
Public KWatch As New FileSystemWatcher
Public OffWatch As New FileSystemWatcher
Public OnWatch As New FileSystemWatcher
Public PassWatch As New FileSystemWatcher
Public RunWatch As New FileSystemWatcher
Public FggWatch As New FileSystemWatcher
Public FgnWatch As New FileSystemWatcher
Public IncWatch As New FileSystemWatcher
Public ToWatch As New FileSystemWatcher
Public PuntOffWatch1 As New FileSystemWatcher
Public PuntDefWatch As New FileSystemWatcher
Public RollMsg As New FileSystemWatcher

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

NKWatch.Path = "C:\PlayC\Qtr2"

NKWatch.Filter = "*.Nkc"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
NKWatch.BeginInit()
AddHandler KWatch.Created, AddressOf KWatch_Created
KWatch.Path = "C:\PlayC\Qtr2"
KWatch.Filter = "*.Kic"
KWatch.IncludeSubdirectories = False
KWatch.EnableRaisingEvents = True
KWatch.BeginInit()

AddHandler OffWatch.Created, AddressOf OffWatch_Created
Try

OffWatch.Path = "\\Localserver\PlayC\"
OffWatch.Filter = "*.off"
OffWatch.IncludeSubdirectories = False
OffWatch.EnableRaisingEvents = 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.IncludeSubdirectories = False
OnWatch.EnableRaisingEvents = True
AddHandler PassWatch.Created, AddressOf PassWatch_Created
PassWatch.Path = "\\Localserver\PlayC\"
PassWatch.Filter = "*.pas"
PassWatch.IncludeSubdirectories = False
PassWatch.EnableRaisingEvents = True
AddHandler RollMsg.Created, AddressOf RollMsg_Created
RollMsg.Path = "\\Localserver\PlayC\"
RollMsg.Filter = "*.rb"
RollMsg.IncludeSubdirectories = False
RollMsg.EnableRaisingEvents = True

AddHandler RunWatch.Created, AddressOf RunWatch_Created
RunWatch.Path = "\\Localserver\PlayC\"
RunWatch.Filter = "*.run"
RunWatch.IncludeSubdirectories = False
RunWatch.EnableRaisingEvents = True

AddHandler PuntOffWatch1.Created, AddressOf PuntOffWatch1_Created
PuntOffWatch1.Path = "\\Localserver\PlayC\"
PuntOffWatch1.Filter = "*.pow"
PuntOffWatch1.IncludeSubdirectories = False
PuntOffWatch1.EnableRaisingEvents = True

AddHandler ToWatch.Created, AddressOf ToWatch_Created
ToWatch.Path = "\\Localserver\PlayC\"
ToWatch.Filter = "*.to"
ToWatch.EnableRaisingEvents = True
ToWatch.IncludeSubdirectories = False

AddHandler FggWatch.Created, AddressOf FggWatch_Created
FggWatch.Path = "\\Localserver\PlayC\"
FggWatch.Filter = "*.fgg"
FggWatch.IncludeSubdirectories = False
FggWatch.EnableRaisingEvents = True
AddHandler FgnWatch.Created, AddressOf FgnWatch_Created
FgnWatch.Path = "\\Localserver\PlayC\"
FgnWatch.Filter = "*.fgn"
FgnWatch.IncludeSubdirectories = False
FgnWatch.EnableRaisingEvents = True

AddHandler IncWatch.Created, AddressOf IncWatch_Created
IncWatch.Path = "\\Localserver\PlayC\"
IncWatch.Filter = "*.inw"
IncWatch.IncludeSubdirectories = False
IncWatch.EnableRaisingEvents = True
AddHandler PuntDefWatch.Created, AddressOf PuntDefWatch_Created
PuntDefWatch.Path = "\\Localserver\PlayC\"
PuntDefWatch.Filter = "*.pdw"
PuntDefWatch.IncludeSubdirectories = False
PuntDefWatch.EnableRaisingEvents = True
End Sub
Private Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
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.FileSystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run(Form2)
End Sub
Private Sub OffWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmOne As Form2
Dim frmOff As New Form2
frmOff.ShowDialog()
End Sub
Private Sub OnWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmOn As New Form2
frmOn.ShowDialog()
End Sub
Private Sub PassWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPass As New Form2
frmPass.ShowDialog()
End Sub
Private Sub RunWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmRun As New Form2
frmRun.ShowDialog()
End Sub
Private Sub FggWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFgg As New Form2
frmFgg.ShowDialog()
End Sub
Private Sub FgnWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFgn As New Form2
frmFgn.ShowDialog()
End Sub
Private Sub IncWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmInc As New Form2
frmInc.ShowDialog()
End Sub
Private Sub ToWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmTo As New Form2
frmTo.ShowDialog()
End Sub
Private Sub PuntOffWatch1_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPO As New Form2
frmPO.ShowDialog()
End Sub
Private Sub PuntDefWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPd As New Form2
frmPd.ShowDialog()
End Sub
Private Sub RollMsg_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmRoll As New Form2
frmRoll.ShowDialog()
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.GetHashCode
'Dim TempFile As String = ("C:\PlayC\Qtr2\" & TimeStamp.ToString())
Dim ext As String = ".pas"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
File.Delete(FileName)
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
Share this Question
Share on Google+
3 Replies


P: n/a
I have never worked with the Filewatcher.. but perhaps this will help you.
http://www.codeproject.com/cs/files/C__FileWatcher.asp

"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.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.Configuration

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.
InitializeComponent()

'Add any initialization after the InitializeComponent() 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.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'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.Diagnostics.DebuggerStepThrough()Private Sub
InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = 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 =
ConfigurationSettings.AppSettings("ConnString")
Protected PrintWinfile As String =
ConfigurationSettings.AppSettings("PrintWinFile")
Protected TempFileSetting As String =
ConfigurationSettings.AppSettings("TempFileSetting ")
Protected WinnerFile As String =
ConfigurationSettings.AppSettings("WinnerFile")
Public NKWatch As New FileSystemWatcher
Public KWatch As New FileSystemWatcher
Public OffWatch As New FileSystemWatcher
Public OnWatch As New FileSystemWatcher
Public PassWatch As New FileSystemWatcher
Public RunWatch As New FileSystemWatcher
Public FggWatch As New FileSystemWatcher
Public FgnWatch As New FileSystemWatcher
Public IncWatch As New FileSystemWatcher
Public ToWatch As New FileSystemWatcher
Public PuntOffWatch1 As New FileSystemWatcher
Public PuntDefWatch As New FileSystemWatcher
Public RollMsg As New FileSystemWatcher

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

NKWatch.Path = "C:\PlayC\Qtr2"

NKWatch.Filter = "*.Nkc"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
NKWatch.BeginInit()
AddHandler KWatch.Created, AddressOf KWatch_Created
KWatch.Path = "C:\PlayC\Qtr2"
KWatch.Filter = "*.Kic"
KWatch.IncludeSubdirectories = False
KWatch.EnableRaisingEvents = True
KWatch.BeginInit()

AddHandler OffWatch.Created, AddressOf OffWatch_Created
Try

OffWatch.Path = "\\Localserver\PlayC\"
OffWatch.Filter = "*.off"
OffWatch.IncludeSubdirectories = False
OffWatch.EnableRaisingEvents = 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.IncludeSubdirectories = False
OnWatch.EnableRaisingEvents = True
AddHandler PassWatch.Created, AddressOf PassWatch_Created
PassWatch.Path = "\\Localserver\PlayC\"
PassWatch.Filter = "*.pas"
PassWatch.IncludeSubdirectories = False
PassWatch.EnableRaisingEvents = True
AddHandler RollMsg.Created, AddressOf RollMsg_Created
RollMsg.Path = "\\Localserver\PlayC\"
RollMsg.Filter = "*.rb"
RollMsg.IncludeSubdirectories = False
RollMsg.EnableRaisingEvents = True

AddHandler RunWatch.Created, AddressOf RunWatch_Created
RunWatch.Path = "\\Localserver\PlayC\"
RunWatch.Filter = "*.run"
RunWatch.IncludeSubdirectories = False
RunWatch.EnableRaisingEvents = True

AddHandler PuntOffWatch1.Created, AddressOf PuntOffWatch1_Created
PuntOffWatch1.Path = "\\Localserver\PlayC\"
PuntOffWatch1.Filter = "*.pow"
PuntOffWatch1.IncludeSubdirectories = False
PuntOffWatch1.EnableRaisingEvents = True

AddHandler ToWatch.Created, AddressOf ToWatch_Created
ToWatch.Path = "\\Localserver\PlayC\"
ToWatch.Filter = "*.to"
ToWatch.EnableRaisingEvents = True
ToWatch.IncludeSubdirectories = False

AddHandler FggWatch.Created, AddressOf FggWatch_Created
FggWatch.Path = "\\Localserver\PlayC\"
FggWatch.Filter = "*.fgg"
FggWatch.IncludeSubdirectories = False
FggWatch.EnableRaisingEvents = True
AddHandler FgnWatch.Created, AddressOf FgnWatch_Created
FgnWatch.Path = "\\Localserver\PlayC\"
FgnWatch.Filter = "*.fgn"
FgnWatch.IncludeSubdirectories = False
FgnWatch.EnableRaisingEvents = True

AddHandler IncWatch.Created, AddressOf IncWatch_Created
IncWatch.Path = "\\Localserver\PlayC\"
IncWatch.Filter = "*.inw"
IncWatch.IncludeSubdirectories = False
IncWatch.EnableRaisingEvents = True
AddHandler PuntDefWatch.Created, AddressOf PuntDefWatch_Created
PuntDefWatch.Path = "\\Localserver\PlayC\"
PuntDefWatch.Filter = "*.pdw"
PuntDefWatch.IncludeSubdirectories = False
PuntDefWatch.EnableRaisingEvents = True
End Sub
Private Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
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.FileSystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run(Form2)
End Sub
Private Sub OffWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmOne As Form2
Dim frmOff As New Form2
frmOff.ShowDialog()
End Sub
Private Sub OnWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmOn As New Form2
frmOn.ShowDialog()
End Sub
Private Sub PassWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPass As New Form2
frmPass.ShowDialog()
End Sub
Private Sub RunWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmRun As New Form2
frmRun.ShowDialog()
End Sub
Private Sub FggWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFgg As New Form2
frmFgg.ShowDialog()
End Sub
Private Sub FgnWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFgn As New Form2
frmFgn.ShowDialog()
End Sub
Private Sub IncWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmInc As New Form2
frmInc.ShowDialog()
End Sub
Private Sub ToWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmTo As New Form2
frmTo.ShowDialog()
End Sub
Private Sub PuntOffWatch1_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPO As New Form2
frmPO.ShowDialog()
End Sub
Private Sub PuntDefWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPd As New Form2
frmPd.ShowDialog()
End Sub
Private Sub RollMsg_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmRoll As New Form2
frmRoll.ShowDialog()
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.GetHashCode
'Dim TempFile As String = ("C:\PlayC\Qtr2\" & TimeStamp.ToString())
Dim ext As String = ".pas"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
File.Delete(FileName)
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

P: n/a
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**************@TK2MSFTNGP04.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**@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.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.Configuration

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.
InitializeComponent()

'Add any initialization after the InitializeComponent() 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.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'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.Diagnostics.DebuggerStepThrough()Private Sub
InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = 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 =
ConfigurationSettings.AppSettings("ConnString")
Protected PrintWinfile As String =
ConfigurationSettings.AppSettings("PrintWinFile ")
Protected TempFileSetting As String =
ConfigurationSettings.AppSettings("TempFileSettin g")
Protected WinnerFile As String =
ConfigurationSettings.AppSettings("WinnerFile")
Public NKWatch As New FileSystemWatcher
Public KWatch As New FileSystemWatcher
Public OffWatch As New FileSystemWatcher
Public OnWatch As New FileSystemWatcher
Public PassWatch As New FileSystemWatcher
Public RunWatch As New FileSystemWatcher
Public FggWatch As New FileSystemWatcher
Public FgnWatch As New FileSystemWatcher
Public IncWatch As New FileSystemWatcher
Public ToWatch As New FileSystemWatcher
Public PuntOffWatch1 As New FileSystemWatcher
Public PuntDefWatch As New FileSystemWatcher
Public RollMsg As New FileSystemWatcher

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

NKWatch.Path = "C:\PlayC\Qtr2"

NKWatch.Filter = "*.Nkc"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
NKWatch.BeginInit()
AddHandler KWatch.Created, AddressOf KWatch_Created
KWatch.Path = "C:\PlayC\Qtr2"
KWatch.Filter = "*.Kic"
KWatch.IncludeSubdirectories = False
KWatch.EnableRaisingEvents = True
KWatch.BeginInit()

AddHandler OffWatch.Created, AddressOf OffWatch_Created
Try

OffWatch.Path = "\\Localserver\PlayC\"
OffWatch.Filter = "*.off"
OffWatch.IncludeSubdirectories = False
OffWatch.EnableRaisingEvents = 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.IncludeSubdirectories = False
OnWatch.EnableRaisingEvents = True
AddHandler PassWatch.Created, AddressOf PassWatch_Created
PassWatch.Path = "\\Localserver\PlayC\"
PassWatch.Filter = "*.pas"
PassWatch.IncludeSubdirectories = False
PassWatch.EnableRaisingEvents = True
AddHandler RollMsg.Created, AddressOf RollMsg_Created
RollMsg.Path = "\\Localserver\PlayC\"
RollMsg.Filter = "*.rb"
RollMsg.IncludeSubdirectories = False
RollMsg.EnableRaisingEvents = True

AddHandler RunWatch.Created, AddressOf RunWatch_Created
RunWatch.Path = "\\Localserver\PlayC\"
RunWatch.Filter = "*.run"
RunWatch.IncludeSubdirectories = False
RunWatch.EnableRaisingEvents = True

AddHandler PuntOffWatch1.Created, AddressOf PuntOffWatch1_Created
PuntOffWatch1.Path = "\\Localserver\PlayC\"
PuntOffWatch1.Filter = "*.pow"
PuntOffWatch1.IncludeSubdirectories = False
PuntOffWatch1.EnableRaisingEvents = True

AddHandler ToWatch.Created, AddressOf ToWatch_Created
ToWatch.Path = "\\Localserver\PlayC\"
ToWatch.Filter = "*.to"
ToWatch.EnableRaisingEvents = True
ToWatch.IncludeSubdirectories = False

AddHandler FggWatch.Created, AddressOf FggWatch_Created
FggWatch.Path = "\\Localserver\PlayC\"
FggWatch.Filter = "*.fgg"
FggWatch.IncludeSubdirectories = False
FggWatch.EnableRaisingEvents = True
AddHandler FgnWatch.Created, AddressOf FgnWatch_Created
FgnWatch.Path = "\\Localserver\PlayC\"
FgnWatch.Filter = "*.fgn"
FgnWatch.IncludeSubdirectories = False
FgnWatch.EnableRaisingEvents = True

AddHandler IncWatch.Created, AddressOf IncWatch_Created
IncWatch.Path = "\\Localserver\PlayC\"
IncWatch.Filter = "*.inw"
IncWatch.IncludeSubdirectories = False
IncWatch.EnableRaisingEvents = True
AddHandler PuntDefWatch.Created, AddressOf PuntDefWatch_Created
PuntDefWatch.Path = "\\Localserver\PlayC\"
PuntDefWatch.Filter = "*.pdw"
PuntDefWatch.IncludeSubdirectories = False
PuntDefWatch.EnableRaisingEvents = True
End Sub
Private Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
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.FileSystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run(Form2)
End Sub
Private Sub OffWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmOne As Form2
Dim frmOff As New Form2
frmOff.ShowDialog()
End Sub
Private Sub OnWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmOn As New Form2
frmOn.ShowDialog()
End Sub
Private Sub PassWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPass As New Form2
frmPass.ShowDialog()
End Sub
Private Sub RunWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmRun As New Form2
frmRun.ShowDialog()
End Sub
Private Sub FggWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFgg As New Form2
frmFgg.ShowDialog()
End Sub
Private Sub FgnWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFgn As New Form2
frmFgn.ShowDialog()
End Sub
Private Sub IncWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmInc As New Form2
frmInc.ShowDialog()
End Sub
Private Sub ToWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmTo As New Form2
frmTo.ShowDialog()
End Sub
Private Sub PuntOffWatch1_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPO As New Form2
frmPO.ShowDialog()
End Sub
Private Sub PuntDefWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPd As New Form2
frmPd.ShowDialog()
End Sub
Private Sub RollMsg_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmRoll As New Form2
frmRoll.ShowDialog()
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.GetHashCode
'Dim TempFile As String = ("C:\PlayC\Qtr2\" &
TimeStamp.ToString())
Dim ext As String = ".pas"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
File.Delete(FileName)
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

P: n/a
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**************@TK2MSFTNGP04.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**@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.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.Configuration

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.
InitializeComponent()

'Add any initialization after the InitializeComponent() 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.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'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.Diagnostics.DebuggerStepThrough()Private Sub
InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = 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 =
ConfigurationSettings.AppSettings("ConnString")
Protected PrintWinfile As String =
ConfigurationSettings.AppSettings("PrintWinFile")
Protected TempFileSetting As String =
ConfigurationSettings.AppSettings("TempFileSetting ")
Protected WinnerFile As String =
ConfigurationSettings.AppSettings("WinnerFile")
Public NKWatch As New FileSystemWatcher
Public KWatch As New FileSystemWatcher
Public OffWatch As New FileSystemWatcher
Public OnWatch As New FileSystemWatcher
Public PassWatch As New FileSystemWatcher
Public RunWatch As New FileSystemWatcher
Public FggWatch As New FileSystemWatcher
Public FgnWatch As New FileSystemWatcher
Public IncWatch As New FileSystemWatcher
Public ToWatch As New FileSystemWatcher
Public PuntOffWatch1 As New FileSystemWatcher
Public PuntDefWatch As New FileSystemWatcher
Public RollMsg As New FileSystemWatcher

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

NKWatch.Path = "C:\PlayC\Qtr2"

NKWatch.Filter = "*.Nkc"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
NKWatch.BeginInit()
AddHandler KWatch.Created, AddressOf KWatch_Created
KWatch.Path = "C:\PlayC\Qtr2"
KWatch.Filter = "*.Kic"
KWatch.IncludeSubdirectories = False
KWatch.EnableRaisingEvents = True
KWatch.BeginInit()

AddHandler OffWatch.Created, AddressOf OffWatch_Created
Try

OffWatch.Path = "\\Localserver\PlayC\"
OffWatch.Filter = "*.off"
OffWatch.IncludeSubdirectories = False
OffWatch.EnableRaisingEvents = 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.IncludeSubdirectories = False
OnWatch.EnableRaisingEvents = True
AddHandler PassWatch.Created, AddressOf PassWatch_Created
PassWatch.Path = "\\Localserver\PlayC\"
PassWatch.Filter = "*.pas"
PassWatch.IncludeSubdirectories = False
PassWatch.EnableRaisingEvents = True
AddHandler RollMsg.Created, AddressOf RollMsg_Created
RollMsg.Path = "\\Localserver\PlayC\"
RollMsg.Filter = "*.rb"
RollMsg.IncludeSubdirectories = False
RollMsg.EnableRaisingEvents = True

AddHandler RunWatch.Created, AddressOf RunWatch_Created
RunWatch.Path = "\\Localserver\PlayC\"
RunWatch.Filter = "*.run"
RunWatch.IncludeSubdirectories = False
RunWatch.EnableRaisingEvents = True

AddHandler PuntOffWatch1.Created, AddressOf PuntOffWatch1_Created
PuntOffWatch1.Path = "\\Localserver\PlayC\"
PuntOffWatch1.Filter = "*.pow"
PuntOffWatch1.IncludeSubdirectories = False
PuntOffWatch1.EnableRaisingEvents = True

AddHandler ToWatch.Created, AddressOf ToWatch_Created
ToWatch.Path = "\\Localserver\PlayC\"
ToWatch.Filter = "*.to"
ToWatch.EnableRaisingEvents = True
ToWatch.IncludeSubdirectories = False

AddHandler FggWatch.Created, AddressOf FggWatch_Created
FggWatch.Path = "\\Localserver\PlayC\"
FggWatch.Filter = "*.fgg"
FggWatch.IncludeSubdirectories = False
FggWatch.EnableRaisingEvents = True
AddHandler FgnWatch.Created, AddressOf FgnWatch_Created
FgnWatch.Path = "\\Localserver\PlayC\"
FgnWatch.Filter = "*.fgn"
FgnWatch.IncludeSubdirectories = False
FgnWatch.EnableRaisingEvents = True

AddHandler IncWatch.Created, AddressOf IncWatch_Created
IncWatch.Path = "\\Localserver\PlayC\"
IncWatch.Filter = "*.inw"
IncWatch.IncludeSubdirectories = False
IncWatch.EnableRaisingEvents = True
AddHandler PuntDefWatch.Created, AddressOf PuntDefWatch_Created
PuntDefWatch.Path = "\\Localserver\PlayC\"
PuntDefWatch.Filter = "*.pdw"
PuntDefWatch.IncludeSubdirectories = False
PuntDefWatch.EnableRaisingEvents = True
End Sub
Private Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
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.FileSystemEventArgs)
Dim Form1 As Form1
Dim Form2 As New Form2
Application.Run(Form2)
End Sub
Private Sub OffWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmOne As Form2
Dim frmOff As New Form2
frmOff.ShowDialog()
End Sub
Private Sub OnWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmOn As New Form2
frmOn.ShowDialog()
End Sub
Private Sub PassWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPass As New Form2
frmPass.ShowDialog()
End Sub
Private Sub RunWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmRun As New Form2
frmRun.ShowDialog()
End Sub
Private Sub FggWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFgg As New Form2
frmFgg.ShowDialog()
End Sub
Private Sub FgnWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFgn As New Form2
frmFgn.ShowDialog()
End Sub
Private Sub IncWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmInc As New Form2
frmInc.ShowDialog()
End Sub
Private Sub ToWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmTo As New Form2
frmTo.ShowDialog()
End Sub
Private Sub PuntOffWatch1_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPO As New Form2
frmPO.ShowDialog()
End Sub
Private Sub PuntDefWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmPd As New Form2
frmPd.ShowDialog()
End Sub
Private Sub RollMsg_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmRoll As New Form2
frmRoll.ShowDialog()
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.GetHashCode
'Dim TempFile As String = ("C:\PlayC\Qtr2\" &
TimeStamp.ToString())
Dim ext As String = ".pas"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
File.Delete(FileName)
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 discussion thread is closed

Replies have been disabled for this discussion.