473,386 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.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
3 1626
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
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...
2
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...
1
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...
8
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...
11
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...
3
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...
0
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...
14
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...
5
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.