PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Help with FileSystemWatcher

Reply

Help with FileSystemWatcher

 
Thread Tools Rate Thread
Old 08-04-2006, 09:22 PM   #1
Nathan Sokalski
Guest
 
Posts: n/a
Default Help with FileSystemWatcher


I have a directory on my site that I keep a bunch of text files in. The
Application keeps the first line of each of these files in an
HttpApplicationState variable as a SortedList. When I add or modify one of
the files in this directory, I want to delete this HttpApplicationState
variable. I tried to do this using the following lines of code in
Global.asax.vb:

Private WithEvents poemfilewatcher As New
IO.FileSystemWatcher(HttpContext.Current.Server.MapPath("/poetry/poems/"))


Private Sub PoemDirModified(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs) Handles poemfilewatcher.Changed,
poemfilewatcher.Created, poemfilewatcher.Deleted

HttpContext.Current.Application.Lock()

HttpContext.Current.Application.Remove("poemlist")

HttpContext.Current.Application.UnLock()

End Sub


Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

poemfilewatcher.IncludeSubdirectories = True

poemfilewatcher.EnableRaisingEvents = True



End Sub


However, when I add, delete, or modify a file in the directory it does seem
to delete the HttpApplicationState variable. Am I forgetting to do
something? Am I doing something wrong? Any help would be appreciated, or
possibly an example. Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off