473,385 Members | 1,587 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,385 software developers and data experts.

Global.aspx And FileSystemWatcher 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 filesystemwatcher?

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

MyCode:

[GLOBAL.ASAX]
<%@ Application language="VB" inherits="myGlobal" Classname="MainApp"
debug="true" %>

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

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

Dim objMyWath as new myWhatcher(Server.MapPath("/repository/") )
try
Application.lock()
Application.Add( "A_objMyWath" , objMyWath )
catch ex as exception
...
finally
application.unlock()
end try

end sub

Public Sub Application_End(sender As Object, e As EventArgs)
Dim fsw = Application("A_objMyWath")
Application.Remove( "A_objMyWath" )
fsw.Dispose()
end sub
----------------------------

[myWhatcher.vb]
public class myWhatcher
'make a FileSystemWatcher with events..
protected WithEvents fsw as new System.IO.FileSystemWatcher

'the path to monitorize
Public pathToAnalize as String

Public Sub New(ByRef path As String)
pathToAnalize = path
'set the FileSystemWatcher object
fsw.IncludeSubdirectories = True
fsw.Path = pathToAnalize
fsw.EnableRaisingEvents = True
end sub

'function fired-up by the event (rename)
Private Sub fsw_OnRename(ByVal sender As System.Object, ByVal e As
System.IO.RenamedEventArgs) Handles FSW.Renamed
Dim swz As StreamWriter = New StreamWriter("L:\pippo\test.txt ")
try
If System.IO.Directory.Exists(e.FullPath) 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 2257
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*******@hotmail.com> wrote in message
news:a0********************************@4ax.com...
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 filesystemwatcher?

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

MyCode:

[GLOBAL.ASAX]
<%@ Application language="VB" inherits="myGlobal" Classname="MainApp"
debug="true" %>

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

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

Dim objMyWath as new myWhatcher(Server.MapPath("/repository/") )
try
Application.lock()
Application.Add( "A_objMyWath" , objMyWath )
catch ex as exception
...
finally
application.unlock()
end try

end sub

Public Sub Application_End(sender As Object, e As EventArgs)
Dim fsw = Application("A_objMyWath")
Application.Remove( "A_objMyWath" )
fsw.Dispose()
end sub
----------------------------

[myWhatcher.vb]
public class myWhatcher
'make a FileSystemWatcher with events..
protected WithEvents fsw as new System.IO.FileSystemWatcher

'the path to monitorize
Public pathToAnalize as String

Public Sub New(ByRef path As String)
pathToAnalize = path
'set the FileSystemWatcher object
fsw.IncludeSubdirectories = True
fsw.Path = pathToAnalize
fsw.EnableRaisingEvents = True
end sub

'function fired-up by the event (rename)
Private Sub fsw_OnRename(ByVal sender As System.Object, ByVal e As
System.IO.RenamedEventArgs) Handles FSW.Renamed
Dim swz As StreamWriter = New StreamWriter("L:\pippo\test.txt ")
try
If System.IO.Directory.Exists(e.FullPath) 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
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...
2
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...
13
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...
3
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...
22
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...
7
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...
2
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...
19
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...
8
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...

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.