0
thanx .. ultimately i have to check the space for comparision but i m not using any button on my page like upload etc ...
after logged in, folder of a particular user is opened and he can create/delete/edit any file by using mouse and keybords (as normally we do when we work on our PC and the space in our hard drives is reduced).
so i want a notifier which can help me detect that user has done something in his folder.
0
You're only other option would be to check how much space is left in each user's folder before they upload a file, if a file is too large which will bump it over its 1GB limit, display an error message to the user.
0
thanx.... but m using web app (asp.net) i cant use windows app.
wat to do ???
0
You can create a service through New Project -> Visual C# -> Windows Service. It will automatically create an OnStart function where you can put your code.
0
ok..but how to create that service ... i dont have any idea ... havnt worked anything like this b4....
0
You might need to create a service which will run on your server to monitor your files since this will run continuously. The page_load is not necessarily the best approach.
0
i have some folders on my FTP server, belongs to particular user. Suppose ihave 10GB total space and i assign 1GB to each user i.e i can accomodate 10 users having 1GB each.
now users can add/delete/edit any type of file to utilize the storage space. All i need to do is to restrict users not to exceed 1gb space for their file storage. For this i want to use FileSystemWatcher to notify me that a user had created/deleted/edited a file so that i can minimize the space from 1gb incase of creation of a file or add a space incase of deletion.
I have this code but i know its not correct b.c the event handlers are in console and i want pure web app.
Please help me in completing my this task. THANX
using System.IO;
using System.Threading;
using System.Diagnostics;
public partial class _Default : System.Web.UI.Page
{
DAL conn;
string connection;
string id = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\project\\Desktop\\BE prj\\dbsan.mdb;Persist Security Info=False";
conn = new DAL(connection);
////*** Opening Respective Folder of a User ***////
DirectoryInfo directories = new DirectoryInfo(@"C:\\Inetpub\\ftproot\\san\\");
//DirectoryInfo directories = new DirectoryInfo(@"C:\");
DirectoryInfo[] folderList = directories.GetDirectories();
if (Request.QueryString["id"] != null)
id = Request.QueryString["id"];
string path = Path.Combine(@"C:\\Inetpub\\ftproot\\san\\", id);
int folder_count = folderList.Length;
for (int j = 0; j < folder_count; j++)
if (Convert.ToString(folderList[j]) == id)
{
Process p = new Process();
p.StartInfo.FileName = path;
p.Start();
}
ClsFileSystemWatcher FSysWatcher = new ClsFileSystemWatcher();
FSysWatcher.FileWatcher(path);
}
public class ClsFileSystemWatcher
{
public void FileWatcher(string InputDir)
{
using (FileSystemWatcher fsw = new FileSystemWatcher())
{
fsw.Path = InputDir;
fsw.Filter = @"*";
fsw.IncludeSubdirectories = true;
fsw.NotifyFilter =
NotifyFilters.FileName |
NotifyFilters.Attributes |
NotifyFilters.LastAccess |
NotifyFilters.LastWrite |
NotifyFilters.Security |
NotifyFilters.Size |
NotifyFilters.CreationTime |
NotifyFilters.DirectoryName;
fsw.Changed += new FileSystemEventHandler(OnChanged);
fsw.Created += new FileSystemEventHandler(OnCreated);
fsw.Deleted += new FileSystemEventHandler(OnDeleted);
fsw.Renamed += new RenamedEventHandler(OnRenamed);
fsw.Error += new ErrorEventHandler(OnError);
fsw.EnableRaisingEvents = true;
//string strOldFile = InputDir + "OldFile.txt";
//string strNewFile = InputDir + "CreatedFile.txt";
//// Making changes in existing file
//using (FileStream stream = File.Open(strOldFile, FileMode.Append))
//{
// StreamWriter sw = new StreamWriter(stream);
// sw.Write("Appending new line in Old File");
// sw.Flush();
// sw.Close();
//}
//// Writing new file on FileSystem
//using (FileStream stream = File.Create(strNewFile))
//{
// StreamWriter sw = new StreamWriter(stream);
// sw.Write("Writing First line into the File");
// sw.Flush();
// sw.Close();
//}
//File.Delete(strOldFile);
//File.Delete(strNewFile);
// Minimum time given to event handler to track new events raised by the filesystem.
Thread.Sleep(1000);
}
}
public static void OnChanged(object source, FileSystemEventArgs e)
{
Console.WriteLine("File " + e.FullPath + " :" + e.ChangeType);
}
public static void OnDeleted(object source, FileSystemEventArgs e)
{
Console.WriteLine("File " + e.FullPath + " :" + e.ChangeType);
}
public static void OnCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine("File " + e.FullPath + " :" + e.ChangeType);
}
public static void OnRenamed(object source, RenamedEventArgs e)
{
Console.WriteLine("File " + e.OldFullPath + " [Changed to] " + e.FullPath);
}
public static void OnError(object source, ErrorEventArgs e)
{
Console.WriteLine("Error " + e.ToString());
}
}
}

0
What exactly are you trying to accomplish?
0
Thats fine if by coding server can track all d folder activities done at d client side .
my server is FTP. so could u help me in coding on server side ??? i need ur guidance in coding. thanx
0
You can only use the FileSystemWatcher to track files on the server hosting your web application, not on the client's machine.