Filewatch传奇继续 [英] Filewatch saga continues

查看:84
本文介绍了Filewatch传奇继续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!


我之前发布过这个问题。我写了一个快速测试项目,我仍然有同样的问题。
有同样的问题。所以我确定我的代码中有些东西我不是正确写的。

基本上我正在创建一个带有基本点击的文件从一个应用程序。

其他应用程序有一个文件监视设置,当它看到新创建的文件时,

它会被提示打开一个新表单。但是在打开表格的时候它就锁定了。


看看我的代码,我做错了什么?或者有更好的方式来做这个吗?谢谢!


Rudy

服务器应用程序

< BEGIN CODE>

Imports System.IO


公共类Form1

继承System.Windows.Forms.Form


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click


Dim TimeStamp As String = Guid.NewGuid.GetHashCode

Dim TempFile As String =" C:\\\\ watch"

Dim ext As String =" .out"

Dim FileName As String = TempFile& TimeStamp& ext $ / $
Dim fs As New FileStream(FileName,FileMode.Create)

fs.Close()

End Sub


结束类

客户端应用程序具有监视程序

< BEGIN CODE>

Imports System.IO

公共类Form2

继承System.Windows.Forms.Form


Public NKWatch As New FileSystemWatcher

>
Private Sub Form2_Load(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理MyBase.Load


AddHandler NKWatch。创建,地址NKWatch_Created

尝试

NKWatch.Path =" C:\\\\ watch"

NKWatch.Filter =" * .out"

NKWatch.IncludeSubdirectories = False

NKWatch.EnableRaisingEvents = True

Catch ERR As Exception

MessageBox.Show(ERR.Message)

结束尝试

结束子


Public Sub NKWatch_Created(ByVal sender As Object,ByVal e As

System.IO.FileSystemEventArgs)

Dim frmFirst As New Form1

Me.Hide()

frmFirst.Show()

Application.DoEvents()

结束子

结束班

解决方案

我想提供一些建议。第一个是(当你正在测试那些不起作用的东西时)是要消除那些没有b $ b的部分(或者可能不是t)影响问题。例如,即使您消除了服务器应用程序,您仍然可以看到问题。从等式。你

可以简单地将文件复制到文件夹中,这也可以。

的原因是你试图缩小范围,涉及的部分越多,将会越难。


当你不确定守望者是否工作时,不要制作并展示表格。您可以再次输出一条简单的消息我看到它。输出

窗口,减少可疑点的数量。


下一个建议是使用调试器。什么是你的客户申请

,当你认为它被锁定了?你想要它做什么?如果我不错,你会发现你的客户端应用程序正在运行但没有显示的表格

。您正在隐藏主窗体并显示Form1。 (你应该

重命名那个类)但它不会像你写的那样保留焦点。

它关闭,事件处理程序退出并且frmFirst超出范围并被销毁。


我不相信它已被锁定我相信你不能看到它是还是

跑步。


Tom

" Rudy" < Ru ** @ discuss.microsoft.com写信息

新闻:CC ************************** ******** @ microsof t.com ...


你好!


我发布了这个问题早。我写了一个快速测试项目,我仍然有同样的问题。
有同样的问题。所以我确定我的代码中有些东西我不是正确写的。

基本上我正在创建一个带有基本点击的文件从一个应用程序。

其他应用程序有一个文件监视设置,当它看到新创建的

文件时,

会提示打开一个新表单。但是在打开表格的时候它就锁定了。


看看我的代码,我做错了什么?或者有更好的方式



这样做?谢谢!


Rudy

服务器应用程序

< BEGIN CODE>

Imports System.IO


公共类Form1

继承System.Windows.Forms.Form


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click


Dim TimeStamp As String = Guid.NewGuid.GetHashCode

Dim TempFile As String =" C:\\\\ watch"

Dim ext As String =" .out"

Dim FileName As String = TempFile& TimeStamp& ext $ / $
Dim fs As New FileStream(FileName,FileMode.Create)

fs.Close()

End Sub


结束类

客户端应用程序具有监视程序

< BEGIN CODE>

Imports System.IO

公共类Form2

继承System.Windows.Forms.Form


Public NKWatch As New FileSystemWatcher

>
Private Sub Form2_Load(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理MyBase.Load


AddHandler NKWatch。创建,地址NKWatch_Created

尝试

NKWatch.Path =" C:\\\\ watch"

NKWatch.Filter =" * .out"

NKWatch.IncludeSubdirectories = False

NKWatch.EnableRaisingEvents = True

Catch ERR As Exception

MessageBox.Show(ERR.Message)

结束尝试

结束子


Public Sub NKWatch_Created(ByVal发送者作为对象,ByVal e As

System.IO.FileSystemEventArgs)

Dim frmFirst As New Form1

Me.Hide()

frmFirst.Show()

Application.DoEvents ()

结束子

结束等级



嗨汤姆!


提出建议。我确实确保我的手表正常工作,但

显示了一个简单的信息框。所以我很高兴。我确实试过了,然后在客户端ap上创建一个点击事件,然后打开第二个表单,那个

工作正常。我知道表单被锁定了,因为几秒钟之后,我得到了

我窗体上的窗口没有响应。当我尝试调试它时,它不会在任何地方停止
。即使我在表单2的表单加载时添加了breka点,

表单1和文件wacther。为了让事情变得更有趣,在我得到

窗口后,询问我是否要停止此程序,你想发送它吗?
Microsoft。我得到一个CS 2003的meesage表示没有源代码

可用于当前位置


所以我不确定在哪里看。我写了这个简单的应用程序,在我的真实程序中删除了所有内容。我希望如果我能让这个工作,我可以用b $ b来修复我的真实应用。


还有其他的想法吗?


谢谢!

Rudy


" Tom Leylan"写道:


我想提供一些建议。第一个是(当你正在测试那些不起作用的东西时)是要消除那些没有b $ b的部分(或者可能不是t)影响问题。例如,即使您消除了服务器应用程序,您仍然可以看到问题。从等式。你

可以简单地将文件复制到文件夹中,这也可以。

的原因是你试图缩小范围,涉及的部分越多,将会越难。


当你不确定守望者是否工作时,不要制作并展示表格。您可以再次输出一条简单的消息我看到它。输出

窗口,减少可疑点的数量。


下一个建议是使用调试器。什么是你的客户申请

,当你认为它被锁定了?你想要它做什么?如果我不错,你会发现你的客户端应用程序正在运行但没有显示的表格

。您正在隐藏主窗体并显示Form1。 (你应该

重命名那个类)但它不会像你写的那样保留焦点。

它关闭,事件处理程序退出并且frmFirst超出范围并被销毁。


我不相信它已被锁定我相信你不能看到它是还是

跑步。


Tom


" Rudy" < Ru ** @ discuss.microsoft.com写信息

新闻:CC ************************** ******** @ microsof t.com ...


你好!


我发布了这个问题早。我写了一个快速测试项目,我仍然有同样的问题。
有同样的问题。所以我确定我的代码中有些东西我不是正确写的。

基本上我正在创建一个带有基本点击的文件从一个应用程序。

其他应用程序有一个文件监视设置,当它看到新创建的

文件时,

会提示打开一个新表单。但是在打开表格的时候它就锁定了。


看看我的代码,我做错了什么?或者有更好的方式



这样做?谢谢!


Rudy

服务器应用程序

< BEGIN CODE>

Imports System.IO


公共类Form1

继承System.Windows.Forms.Form


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click


Dim TimeStamp As String = Guid.NewGuid.GetHashCode

Dim TempFile As String =" C:\\\\ watch"

Dim ext As String =" .out"

Dim FileName As String = TempFile& TimeStamp& ext $ / $
Dim fs As New FileStream(FileName,FileMode.Create)

fs.Close()

End Sub


结束类

客户端应用程序具有监视程序

< BEGIN CODE>

Imports System.IO

公共类Form2

继承System.Windows.Forms.Form


Public NKWatch As New FileSystemWatcher

>
Private Sub Form2_Load(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理MyBase.Load


AddHandler NKWatch。创建,地址NKWatch_Created

尝试

NKWatch.Path =" C:\\\\ watch"

NKWatch.Filter =" * .out"

NKWatch.IncludeSubdirectories = False

NKWatch.EnableRaisingEvents = True

Catch ERR As Exception

MessageBox.Show(ERR.Me ssage)

结束尝试

结束子


Public Sub NKWatch_Created(ByVal发送者作为对象,ByVal e As

System.IO.FileSystemEventArgs)

Dim frmFirst As New Form1

Me.Hide()

frmFirst.Show()

Application.DoEvents()

结束子

结束班




嗨!


AFAIK在自己的主题中运行你的AddressOf NKWatch_Created你不能(

或多或少在praxis中)使用主线程的messagpump表单。


你可以尝试(但我不推荐)是一个application.start(form2 )

创建一个新的消息泵。或者更好(我认为)对请求进行排队并使用计时器或监视器开始处理
。当更多

然后创建1个文件并且你已经打开一个表格时想想问题。

Wolfgang


" ;鲁迪" < Ru ** @ discussion.microsoft.comschrieb im Newsbeitrag

news:B4 ************************** ******** @ microsof t.com ...


嗨汤姆!


建议。我确实确保我的手表正常工作,但

显示了一个简单的信息框。所以我很高兴。我确实试过了,然后在客户端ap上创建一个点击事件,并打开第二个表单,并且



工作正常。我知道表格被锁定了,因为几秒钟之后,我就会在我的表格窗口上没有回复的情况下获得

。当我尝试调试它时,

不会

停在任何地方。即使我把breka积分,形式加载形式

2,

表格1和文件wacther。并且为了让事情变得更有趣,在我获得

窗口之后,询问我是否要停止此程序,是否要发送它

微软。我得到一个CS 2003的meesage表示没有源代码

可用于当前位置


所以我不确定在哪里看。我写了这个简单的应用程序,在我的真实程序中删除了所有内容。我希望如果我能让这个工作,我可以用b $ b来修复我的真实应用。


还有其他的想法吗?


谢谢!

Rudy


" Tom Leylan"写道:


>我想提供一些建议。第一个是
(当你正在测试那些不起作用的东西时)是要消除那些不会(或者可能不是)的部分。 t)影响问题。例如,即使您消除了服务器应用程序,您仍然可以看到问题。等式。
你可以简单地将文件复制到文件夹中,这也可以。原因在于你试图缩小范围,涉及的部分越多越难。

并且不要创造当你不确定观察者是否正在工作时,并显示一个表格。您可以再次输出一条简单的消息我看到它。到输出窗口并减少可疑点的数量。

下一个建议是使用调试器。当您认为它被锁定时,您的客户
申请是做什么的?你想要它做什么?如果
我没有弄错,你会发现你的客户端应用程序正在运行但没有显示
表格。您正在隐藏主窗体并显示Form1。 (你应该重命名那个班级),但它不会像你写的那样保留焦点
它关闭,事件处理程序退出并且frmFirst超出范围,
被摧毁。

我不相信它被锁定我相信你不能看到它仍然是
跑步。

Tom

" Rudy" < Ru ** @ discussion.microsoft.com写信息
新闻:CC ****************************** **** @ microso ft.com ...


你好!


我之前发布过这个问题。我写了一个快速测试项目,而我还是b $ b仍然

有同样的问题。所以我确定我的代码中有些东西我是

不是

写得正确。

基本上我是'从一个应用程序创建一个带有邻接点击的文件。



其他应用程序有一个文件监视设置,当它看到新创建的

文件,

提示打开一个新表单。但它最终锁定了



打开表格。


看看我的代码,什么我做错了吗?或者有更好的

方式



这样做?谢谢!


Rudy

服务器应用程序

< BEGIN CODE>

Imports System.IO


公共类Form1

继承System.Windows.Forms.Form


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click


Dim TimeStamp As String = Guid.NewGuid.GetHashCode

Dim TempFile As String =" C:\\\\ watch"

Dim ext As String =" .out"

Dim FileName As String = TempFile& TimeStamp& ext $ / $
Dim fs As New FileStream(FileName,FileMode.Create)

fs.Close()

End Sub


结束类

客户端应用程序具有监视程序

< BEGIN CODE>

Imports System.IO

公共类Form2

继承System.Windows.Forms.Form


Public NKWatch As New FileSystemWatcher

>
Private Sub Form2_Load(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理MyBase.Load


AddHandler NKWatch。创建,地址NKWatch_Created

尝试

NKWatch.Path =" C:\\\\ watch"

NKWatch.Filter =" * .out"

NKWatch.IncludeSubdirectories = False

NKWatch.EnableRaisingEvents = True

Catch ERR As Exception

MessageBox.Show(ERR.Message)

结束尝试

结束子


Public Sub NKWatch_Created(ByVal发送者作为对象,ByVal e As

System.IO.FileSystemEventArgs)

Dim frmFirst As New Form1

Me.Hide()

frmFirst.Show()

Application.DoEvents ()

结束子

结束班





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.

Take a look at my code, what am I doing wrong? Or is there a better way of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class

解决方案

There are a couple of suggestions I would like to offer. The first is (when
you''re testing things that don''t work) is to eliminate the parts that don''t
(or probably don''t) impact the problem. You could for instance still see
the problem even if you eliminate the "server app" from the equation. You
can simply copy a file into the folder and that will work as well. The
reason is that you''re trying to narrow things down, the more pieces involved
the harder that will be.

And don''t create and show a form when you''re not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client application
doing when you think it has locked up? What do you want it to do? If I''m
not mistaken you''ll find that your client app is running but without a form
on display. You are hiding the main form and showing a "Form1" (you should
rename that class) but it won''t retain the focus the way you''ve written it.
It closes, the event handler is exited and frmFirst goes out of scope and is
destroyed.

I don''t believe it has locked up I believe you can''t see that it is still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microsof t.com...

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.

Take a look at my code, what am I doing wrong? Or is there a better way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class



Hi Tom!

Thnks for the suggestions. I did make sure my watch works properly, but
having a s simple message box displayed. So I''m good there. I did try and
create a click event on the client ap, and open up the second form, and that
works fine. Iknow the form is locked up, because after a few seconds, I get
a non-responding on the window on my form. When I try to debug it, it doesnt
stop anywhere. Even when I put breka points, at the form load of the form 2,
form 1 and the file wacther. And to make things more intersting, after I get
the window that ask if I want to stop this program, do you want to send it
Microsoft. I get a meesage form CS 2003 that says "There is no source code
avaiable for the current location"

So I''m not sure sure where to look. I wrote this simple app, eleminating
everything elses in my real program. I hope if I can get this to work, I
might be able to fix my real application.

Any other thoughts?

Thanks!
Rudy

"Tom Leylan" wrote:

There are a couple of suggestions I would like to offer. The first is (when
you''re testing things that don''t work) is to eliminate the parts that don''t
(or probably don''t) impact the problem. You could for instance still see
the problem even if you eliminate the "server app" from the equation. You
can simply copy a file into the folder and that will work as well. The
reason is that you''re trying to narrow things down, the more pieces involved
the harder that will be.

And don''t create and show a form when you''re not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client application
doing when you think it has locked up? What do you want it to do? If I''m
not mistaken you''ll find that your client app is running but without a form
on display. You are hiding the main form and showing a "Form1" (you should
rename that class) but it won''t retain the focus the way you''ve written it.
It closes, the event handler is exited and frmFirst goes out of scope and is
destroyed.

I don''t believe it has locked up I believe you can''t see that it is still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microsof t.com...

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.

Take a look at my code, what am I doing wrong? Or is there a better way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class




Hi!

AFAIK runs your AddressOf NKWatch_Created in an own thread and you can''t (
more or less in praxis) use a form with the messagpump of the main thread.

What you can try (but i don''t recommend) is a application.start(form2) to
create a new messagepump. Or better ( i think) queue the request and start
processing with a timer or a monitor. And think about the problem when more
then 1 file is created and you have a form already open.
Wolfgang

"Rudy" <Ru**@discussions.microsoft.comschrieb im Newsbeitrag
news:B4**********************************@microsof t.com...

Hi Tom!

Thnks for the suggestions. I did make sure my watch works properly, but
having a s simple message box displayed. So I''m good there. I did try and
create a click event on the client ap, and open up the second form, and
that
works fine. Iknow the form is locked up, because after a few seconds, I
get
a non-responding on the window on my form. When I try to debug it, it
doesnt
stop anywhere. Even when I put breka points, at the form load of the form
2,
form 1 and the file wacther. And to make things more intersting, after I
get
the window that ask if I want to stop this program, do you want to send it
Microsoft. I get a meesage form CS 2003 that says "There is no source code
avaiable for the current location"

So I''m not sure sure where to look. I wrote this simple app, eleminating
everything elses in my real program. I hope if I can get this to work, I
might be able to fix my real application.

Any other thoughts?

Thanks!
Rudy

"Tom Leylan" wrote:

>There are a couple of suggestions I would like to offer. The first is
(when
you''re testing things that don''t work) is to eliminate the parts that
don''t
(or probably don''t) impact the problem. You could for instance still see
the problem even if you eliminate the "server app" from the equation.
You
can simply copy a file into the folder and that will work as well. The
reason is that you''re trying to narrow things down, the more pieces
involved
the harder that will be.

And don''t create and show a form when you''re not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client
application
doing when you think it has locked up? What do you want it to do? If
I''m
not mistaken you''ll find that your client app is running but without a
form
on display. You are hiding the main form and showing a "Form1" (you
should
rename that class) but it won''t retain the focus the way you''ve written
it.
It closes, the event handler is exited and frmFirst goes out of scope and
is
destroyed.

I don''t believe it has locked up I believe you can''t see that it is still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microso ft.com...

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.

Take a look at my code, what am I doing wrong? Or is there a better
way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class





这篇关于Filewatch传奇继续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆