1

I want to monitor the activities of all the folders present at "C:\Inetpub\ftproot\san".User can work on any type of files and not only text files.Since we have given 1GB space (lets say) to each user, so user can do anything to utilize this space.

Now I want to monitor the activites that the user will do in his folder like creating new file, deleting an existing file or editing a file.I want to monitor user's activities because i have to keep track of the space given to the user so tht i can restrict the user to use 1GB space only and not more than that. is there any class that i can use other than FileSystemWatcher as it works only in console applications and not in webapplications?? any help would be highly apperciated.. Many thanks

ariez88
  • 11
  • 1

4 Answers4

0

FileSystemWatcher should work just fine in a web application, but the problem is that the web application isn't always on. If nobody accesses it for a while, it can be shut down in lieu of other things that need resources and then started again when next accessed. It can also be re-started easily when things within its own structure change (such as its config file). It's very stateless and transient.

How do you plan to use this information within the web application? Does your web application really need to be constantly watching, or does it just need to generate a report of the current state of the filesystem when requested? If you really need the former, then the aforementioned nature of how web applications run on the server will make things a bit unreliable. Maybe a Windows service running on the web server would be more up to the task?

David
  • 208,112
  • 36
  • 198
  • 279
  • Is the website the only way the user(s) can access their files? That is, all uploads/deletes/edits/etc. are strictly done through the website and never directly on the filesystem or through FTP or anything? If so then you don't really need to monitor constantly, just check each time an operation is performed if it will violate the limit and, if so, return an error. – David Jun 24 '10 at 18:46
0

First, I would break this down into:

  • What are the possible ways users can modify the contents of the folder?
  • What are you trying to accomplish/present to the user via the Web interface?

One way to do this somewhat simply (in a sense) would be to maintain a service on the machine that periodically monitors the directory for the information you need (size, # of files, whatever), and connect this (via something like WCF) to the actual web application. In effect, you'd have a semi-soft limit, in that for a period users could operate on more than 1GB, but there are obviously corrective measures you could take, but this way you don't actually have to monitor every action of every user in realtime.


Marc Bollinger
  • 3,109
  • 2
  • 27
  • 32
  • thanks for ur reply. user can save any type of files in his space, also he can edit text files.. he can delete all types of files. for modifying the contents he can use click of the mouse or keystrokes. the web intrface will have a login page where user will enter his id and password and as he presses login button he will be redireted to a page that will contain only his folder.within his folder user can perform any kind of file operation. – ariez88 Jun 24 '10 at 18:42
0

Off the cuff I would think that you need some sort of service to use the FileSystemWatcher class. The only way to really watch over the directory using asp.net is if you are controlling how all files get added and deleted from the directory. If that is the case then you can add code to skim through the directory and add the sizes of everything in there pretty easily.

If they can put files in these folders with other applications (such as an FTP client) then you are going to need a service to watch over the folders.

jaltiere
  • 1,068
  • 6
  • 11
  • thanks Jaltiere. Yes my server is on FTP and user will be uploading files to the website through his local pc over the internet.Is thereany wa i can use FileSystemWatcher in ASP.NET? – ariez88 Jun 24 '10 at 18:46
  • You could try setting it up in the Application_Start event in the global.asax file, but the key would be to make sure you always have at least 1 active session. If you have a lot of traffic this might not be an issue, but if not you will need to come up with some sort of keep-alive solution. – jaltiere Jun 24 '10 at 19:33
0

A better way of doing this is let your WebApp run as a portal to what's happening, but you will need a windows service running to ensure that someone does not go over the space allotment.

The service would also be able to help give data to your portal.

Remember, a website only runs when someone calls it. So if you don't use your website for 5 days, nothing will monitor it.

Sure you could keep a web page open for X amount of days, but that's overkill.

Ryan Ternier
  • 8,714
  • 4
  • 46
  • 69