ASP.NET应用程序和FileSystemWatcher [英] ASP.NET Application and FileSystemWatcher

查看:69
本文介绍了ASP.NET应用程序和FileSystemWatcher的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个asp.net应用程序,这是一个3层应用程序。我是

用来创建一个监视文件夹并获取文件的组件和

将它们传递给我们的业务逻辑层中的类库(到目前为止很好并且很容易)。我初始化我的类,这是在我的

Global中使用FileSystemWatcher .asax和一切正常。我发现FileSystemWatcher类

不太可靠,有时候它会出乎意料地行为。我很无聊它

降低了整个应用程序。有没有更好的方法这样做

**在Asp.Net应用程序内**。我不能使用像windows这样的其他应用程序

服务或schedault taks.Everything需要做的是ASP.NET

应用程序。

非常感谢

解决方案

你好JT,

我发现FileSystemWatcher类不太可靠,有时它会表现得很好我出乎意料地说,它打倒了整个
应用程序。


FileSystemWatcher类非常可靠。但是,它使用的事件,

与您的应用程序是异步的。如果不了解更多关于

如何编写代码的信息,我就不能告诉你更多了。例如,

" Global.asax"是一个文件。编译时生成的Global类是一个类。它包含许多事件,你不能在一个事件中存储一个

类。所以,我不知道你在哪里坚持你的课程,或者

如何。另外,您提到您创建了组件,其中最有可能是
不是组件。在字面上.Net意义上的术语。所以,我知道

也没什么关系。


-

HTH,


Kevin Spencer

Microsoft MVP

..Net开发人员

有时候你吃大象。

有时候大象吃了你。


J-T <太阳神**** @ microsft.com>写在消息

新闻:%2 **************** @ TK2MSFTNGP15.phx.gbl ...我们正在开发一个asp.net应用程序是一个3层的应用程序。我很想创建一个监视文件夹并获取文件的组件,并将它们传递给我们业务逻辑层中的类库(到目前为止这样)
好的,简单的。我在我的Global.asax中初始化我正在使用FileSystemWatcher的类,一切正常。我发现FileSystemWatcher
类不太可靠,有时它会出乎意料地行为。我是afriad
它打倒了整个应用程序。有一个更好的方法来做这个**里面的Asp.Net应用程序**。我不能使用像
windows服务这样的另一个应用程序或者schedault tak。所有需要做的就是ASP.NET
应用程序。

非常感谢



Are你确定你走在正确的轨道上?一个FileSystemWatcher对象必须存在于某处才能观看的
。一个asp.net应用程序不存在

,但在客户端http请求和服务器响应之间。非常短暂的时间。你是否希望观察者只在

服务器忙于服务客户请求时才能抓到东西?


Eliyahu

" J -T" <太阳神**** @ microsft.com>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP15.phx.gbl ...

我们是在asp.net应用程序上工作,这是一个3层应用程序.I
用于创建一个监视文件夹并获取文件的组件,并将它们传递给业务逻辑层中的类库(到目前为止这么好的
和简单)。我初始化我的类,我在我的
Global.asax中使用FileSystemWatcher,一切正常。我发现FileSystemWatcher
类不太可靠,有时候它出乎意料地表现得很好。我很无愧,因为它会降低整个应用程序的价值。有更好的方法可以做到这一点
**内部Asp.Net应用程序**。我不能使用另一个应用程序,如
windows服务或schedault taks.Everything需要做的是ASP.NET
应用程序。

非常感谢



我忘了说我监控的目录是
$ b上的共享文件夹$ b netwrok。


谢谢

" Eliyahu Goldin" <再************* @ monarchmed.com>在消息中写道

news:ud ************** @ TK2MSFTNGP09.phx.gbl ...

你确定你是在正确的轨道上? FileSystemWatcher对象必须存在于某个能够观看的地方。除了客户端http请求和服务器响应之间的任何地方,asp.net应用程序都不存在。非常短暂的时间。你是否希望观察者只在服务器忙于服务客户请求时才能抓到东西?

Eliyahu

J-T <太阳神**** @ microsft.com>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP15.phx.gbl ...

我们正在研究一个asp .net应用程序,这是一个3层应用程序。我


aksed创建一个监视文件夹并获取文件的组件,并将它们传递给我们的业务逻辑层中的类库(到目前为止很好


简单)。我初始化我的类,它在我的
Global中使用了FileSystemWatcher。 asax和一切正常。我发现FileSystemWatcher


class

不太可靠,有时它会出乎意料地行事。我很无视


关闭整个应用程序。有更好的方法这样做
**在Asp.Net应用程序内部**。我不能使用像

这样的其他应用程序
windows

服务或schedaul需要做的就是ASP.NET
应用程序。

非常感谢




We are working on an asp.net application which is a 3-tier application.I was
aksed to create a component which monitors a folder and gets the file and
pass them to a class library in our business logic layer(so far so good and
easy).I initialize my class which is using a FileSystemWatcher in my
Global.asax and everything works fine.I have found FileSystemWatcher class
not very reliable and sometimes it behavies unexpectedly.I''m afriad that it
brings down the whole application.Is there a better way of doing this
**Inside Asp.Net application**.I can''t use antother application like windows
service or schedault taks.Everything needs to be done is ASP.NET
application.
Thanks a lot

解决方案

Hi J-T,

I have found FileSystemWatcher class not very reliable and sometimes it
behavies unexpectedly.I''m afriad that it brings down the whole
application.
The FileSystemWatcher class is very reliable. However, it uses events, which
are asynchronous to your application. Without knowing anything more about
how your code is written, I can''t tell you much more. For example,
"Global.asax" is a file. The Global class that is generated when it is
compiled is a class. It contains a number of events, and you can''t store a
class in an event. So, I have no idea where you''re persisting your class, or
how. Also, you mentioned that you created a "component," which most probably
is not a "Component" in the literal .Net sense of the term. So, I know
nothing about that either.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"J-T" <Ra****@microsft.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... We are working on an asp.net application which is a 3-tier application.I
was aksed to create a component which monitors a folder and gets the file
and pass them to a class library in our business logic layer(so far so
good and easy).I initialize my class which is using a FileSystemWatcher in
my Global.asax and everything works fine.I have found FileSystemWatcher
class not very reliable and sometimes it behavies unexpectedly.I''m afriad
that it brings down the whole application.Is there a better way of doing
this **Inside Asp.Net application**.I can''t use antother application like
windows service or schedault taks.Everything needs to be done is ASP.NET
application.
Thanks a lot



Are you sure you are on the right track? A FileSystemWatcher object has to
exist somewhere to be able to watch. An asp.net application doesn''t exist
anywhere but between a client http request and the server response. A very
short time. Do you expect the watcher to catch something only when the
server is busy serving client requests?

Eliyahu
"J-T" <Ra****@microsft.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...

We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and
pass them to a class library in our business logic layer(so far so good and easy).I initialize my class which is using a FileSystemWatcher in my
Global.asax and everything works fine.I have found FileSystemWatcher class not very reliable and sometimes it behavies unexpectedly.I''m afriad that it brings down the whole application.Is there a better way of doing this
**Inside Asp.Net application**.I can''t use antother application like windows service or schedault taks.Everything needs to be done is ASP.NET
application.
Thanks a lot



I forgot to say that directory which I monitor is a shared folder on the
netwrok.

Thanks
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl...

Are you sure you are on the right track? A FileSystemWatcher object has to
exist somewhere to be able to watch. An asp.net application doesn''t exist
anywhere but between a client http request and the server response. A very
short time. Do you expect the watcher to catch something only when the
server is busy serving client requests?

Eliyahu
"J-T" <Ra****@microsft.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...

We are working on an asp.net application which is a 3-tier application.I


was

aksed to create a component which monitors a folder and gets the file and
pass them to a class library in our business logic layer(so far so good


and

easy).I initialize my class which is using a FileSystemWatcher in my
Global.asax and everything works fine.I have found FileSystemWatcher


class

not very reliable and sometimes it behavies unexpectedly.I''m afriad that


it

brings down the whole application.Is there a better way of doing this
**Inside Asp.Net application**.I can''t use antother application like


windows

service or schedault taks.Everything needs to be done is ASP.NET
application.
Thanks a lot




这篇关于ASP.NET应用程序和FileSystemWatcher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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