G
Guest
Hi,
I use FileSystemWatcher in a module with a Main() function that loads some
Forms (Window Forms Application). The starting object of the application is
not a hidden form but a module. I have to use the Application.Run()
statement, without that the application exits. FileSystemWatcher watches the
creation of a xml file called IN.xml. when a file is created,
FileSystemWatcher fires the Create Event but when I try to show the Form, the
application hangs.
Someone has an answer or a documentation which can explain that "problem".
A dummy example :
-----------------------
Public Module MainMod
Private WithEvents FSW As IO.FileSystemWatcher
Private applicContexte As System.Windows.Forms.ApplicationContext
Private Frm As Form
Public Sub Main()
FSW = New IO.FileSystemWatcher("c:\", "IN.xml")
FSW.NotifyFilter = IO.NotifyFilters.LastWrite Or
IO.NotifyFilters.FileName Or IO.NotifyFilters.DirectoryName Or
IO.NotifyFilters.LastAccess
FSW.EnableRaisingEvents = True
applicContexte = New System.Windows.Forms.ApplicationContext
Application.Run(applicContexte)
End Sub
Private Sub FSW_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs) Handles FSW.Created
Frm = New Form
Frm.Show()
Frm.Controls.Add(New TextBox)
Frm.Refresh()
End Sub
End Module
Thank for your help !
I use FileSystemWatcher in a module with a Main() function that loads some
Forms (Window Forms Application). The starting object of the application is
not a hidden form but a module. I have to use the Application.Run()
statement, without that the application exits. FileSystemWatcher watches the
creation of a xml file called IN.xml. when a file is created,
FileSystemWatcher fires the Create Event but when I try to show the Form, the
application hangs.
Someone has an answer or a documentation which can explain that "problem".
A dummy example :
-----------------------
Public Module MainMod
Private WithEvents FSW As IO.FileSystemWatcher
Private applicContexte As System.Windows.Forms.ApplicationContext
Private Frm As Form
Public Sub Main()
FSW = New IO.FileSystemWatcher("c:\", "IN.xml")
FSW.NotifyFilter = IO.NotifyFilters.LastWrite Or
IO.NotifyFilters.FileName Or IO.NotifyFilters.DirectoryName Or
IO.NotifyFilters.LastAccess
FSW.EnableRaisingEvents = True
applicContexte = New System.Windows.Forms.ApplicationContext
Application.Run(applicContexte)
End Sub
Private Sub FSW_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs) Handles FSW.Created
Frm = New Form
Frm.Show()
Frm.Controls.Add(New TextBox)
Frm.Refresh()
End Sub
End Module
Thank for your help !