473,667 Members | 2,589 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global.aspx And FileSystemWatch er Problem

Hi!
I try to develop a simple system for monitoring a sub directory of a
web site and remake an xml file every time a sub-dir change it's name.
I don't wont to use a window.service because, i want to use the same
system in many web-site.

I have just write some line of code...but i have a problem:
when i change the name of a file..i fire-up the Application_end events
.... why?
how i can meange the event of the filesystemwatch er?

Tnx at all for any suggestion.
Please ...escuse me for my english!!!
Bye

MyCode:

[GLOBAL.ASAX]
<%@ Application language="VB" inherits="myGlo bal" Classname="Main App"
debug="true" %>

[GLOBAL.VB]
Protected Sub Application_sta rt(sender As Object, e As EventArgs)

'myWhatcher is the my object that will be store in the application

Dim objMyWath as new myWhatcher(Serv er.MapPath("/repository/") )
try
Application.loc k()
Application.Add ( "A_objMyWat h" , objMyWath )
catch ex as exception
...
finally
application.unl ock()
end try

end sub

Public Sub Application_End (sender As Object, e As EventArgs)
Dim fsw = Application("A_ objMyWath")
Application.Rem ove( "A_objMyWat h" )
fsw.Dispose()
end sub
----------------------------

[myWhatcher.vb]
public class myWhatcher
'make a FileSystemWatch er with events..
protected WithEvents fsw as new System.IO.FileS ystemWatcher

'the path to monitorize
Public pathToAnalize as String

Public Sub New(ByRef path As String)
pathToAnalize = path
'set the FileSystemWatch er object
fsw.IncludeSubd irectories = True
fsw.Path = pathToAnalize
fsw.EnableRaisi ngEvents = True
end sub

'function fired-up by the event (rename)
Private Sub fsw_OnRename(By Val sender As System.Object, ByVal e As
System.IO.Renam edEventArgs) Handles FSW.Renamed
Dim swz As StreamWriter = New StreamWriter("L :\pippo\test.tx t ")
try
If System.IO.Direc tory.Exists(e.F ullPath) Then
... some operation
End If
catch ex as Exception
end try

End Sub

public sub dispose()
fsw.dispose()
end sub

end class
Nov 19 '05 #1
1 2277
asp.net also uses a filewatcher. when it detects a change, it recycles the
site, thus your Application_end .

a windows service is the best choice.

-- bruce (sqlwork.com)

"PadovaBoy" <pa*******@hotm ail.com> wrote in message
news:a0******** *************** *********@4ax.c om...
Hi!
I try to develop a simple system for monitoring a sub directory of a
web site and remake an xml file every time a sub-dir change it's name.
I don't wont to use a window.service because, i want to use the same
system in many web-site.

I have just write some line of code...but i have a problem:
when i change the name of a file..i fire-up the Application_end events
... why?
how i can meange the event of the filesystemwatch er?

Tnx at all for any suggestion.
Please ...escuse me for my english!!!
Bye

MyCode:

[GLOBAL.ASAX]
<%@ Application language="VB" inherits="myGlo bal" Classname="Main App"
debug="true" %>

[GLOBAL.VB]
Protected Sub Application_sta rt(sender As Object, e As EventArgs)

'myWhatcher is the my object that will be store in the application

Dim objMyWath as new myWhatcher(Serv er.MapPath("/repository/") )
try
Application.loc k()
Application.Add ( "A_objMyWat h" , objMyWath )
catch ex as exception
...
finally
application.unl ock()
end try

end sub

Public Sub Application_End (sender As Object, e As EventArgs)
Dim fsw = Application("A_ objMyWath")
Application.Rem ove( "A_objMyWat h" )
fsw.Dispose()
end sub
----------------------------

[myWhatcher.vb]
public class myWhatcher
'make a FileSystemWatch er with events..
protected WithEvents fsw as new System.IO.FileS ystemWatcher

'the path to monitorize
Public pathToAnalize as String

Public Sub New(ByRef path As String)
pathToAnalize = path
'set the FileSystemWatch er object
fsw.IncludeSubd irectories = True
fsw.Path = pathToAnalize
fsw.EnableRaisi ngEvents = True
end sub

'function fired-up by the event (rename)
Private Sub fsw_OnRename(By Val sender As System.Object, ByVal e As
System.IO.Renam edEventArgs) Handles FSW.Renamed
Dim swz As StreamWriter = New StreamWriter("L :\pippo\test.tx t ")
try
If System.IO.Direc tory.Exists(e.F ullPath) Then
... some operation
End If
catch ex as Exception
end try

End Sub

public sub dispose()
fsw.dispose()
end sub

end class

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2997
by: cxw0106 | last post by:
Hello, I have some weird problem with the FileSystemWatcher. I have developed an application that monitors a network directory for file changes of a certain file type. The program runs well for a week. Then suddenly the monitored network server starts to behave crazily. It sends to my Sync Server dozens of replicated file change events. Say one file was changed two days ago, but the monitored server still keeps sending me many many...
2
4816
by: Paul | last post by:
Hi, I've been developing an application in VB.NET that uses the FileSystemWatcher and a popup notification in order to tell me when files have been downloaded. The FileSystemWatcher code in my project is basically the same one thats floating all over the VB.NET sites (by Jayesh Jain). The popup notification (called TaskbarNotifier) is a class originally by John O'Byrne written in C# and C++ but ported to VB.NET by Patrick Vanden...
13
9165
by: David | last post by:
I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just multiple directories. I have hit a snag and don't know how to get around it. Basically I read in a list of directories from the app.config and stuff them into an array, so that I have something like this: sDirsToWatch = "C:\Temp"
3
4596
by: Stampede | last post by:
Hi, I write an application which waits for incomming files in a specified directory. I thought, that using the FileSystemWatcher would be the best, as it does exactly what I need. But now I have a problem: I wonna get shure, that really all files are processed and I need to be shure, that no file is processed twice. If my application is started while there are already files in the directory (which is realistic, as the application could...
22
3768
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to manipulate them. It starts > and ends with <script></script> tags. > > Yours looks like a compiled version of it.
7
5216
by: Ankit Aneja | last post by:
I put the code for url rewrite in my Application_BeginRequest on global.ascx some .aspx pages are in root ,some in folder named admin and some in folder named user aspx pages which are in user folder are using this code of url rewrite project is running completely fine on localhost but after uploading first page (http://emailware.net.temporary.domain.name/user/index.aspx) is fine but as i click 123 Easy-CD Ripper
2
1985
by: kmcnet | last post by:
Hello Everyone and thanks for your help in advance. I have been battling a problem for nearly a month with the FileSystemWatcher component. Basically, what I am trying to do it to monitor three separate folders on a Windows 2000 server for activity. In my code, I have set up three separate subroutines: FaxWatch() ReportWatch() ScheduleWatch() Each of the subroutines creates a new instance of the FileSystemWatcher.
19
10190
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another app using web application projects and it's firing fine but it was upgraded from the 1.1 framework. Why doesn't my global.asax application_error routine fire?
8
13189
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project compiles & runs fine locally, but when I copy to the production machine, I get this error: Parser Error Message: Could not load type 'Global'. Source Error: Line 1: <%@ Application Codebehind="Global.asax.vb" Inherits="Global" %> Source...
0
8365
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8788
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.