Click here to Skip to main content
15,895,462 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Is any problem in Image Uploading in IE7? Pin
Sandeep Mewara24-Jun-10 19:43
mveSandeep Mewara24-Jun-10 19:43 
GeneralRe: Is any problem in Image Uploading in IE7? Pin
raju melveetilpurayil25-Jun-10 13:28
professionalraju melveetilpurayil25-Jun-10 13:28 
Questionhow to insert digital signature in Word Application from Sql Server database in Windows Application Pin
raghvendrapanda24-Jun-10 9:28
raghvendrapanda24-Jun-10 9:28 
Questionkeep track of folder's activities Pin
ariez8824-Jun-10 8:32
ariez8824-Jun-10 8:32 
AnswerRe: keep track of folder's activities Pin
Paladin200024-Jun-10 11:25
Paladin200024-Jun-10 11:25 
GeneralRe: keep track of folder's activities Pin
ariez8824-Jun-10 21:36
ariez8824-Jun-10 21:36 
GeneralRe: keep track of folder's activities Pin
Paladin200025-Jun-10 3:46
Paladin200025-Jun-10 3:46 
GeneralRe: keep track of folder's activities Pin
ariez8827-Jun-10 4:33
ariez8827-Jun-10 4:33 
SENARIO: i have few folders on my FTP server, belongs to particular user. Suppose i have 10GB total space and i assign 1GB to each user i.e 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.

this is the piece of coding using FSW. when user gets loged-in with proper id and password, respective folder is opened (present at FTP server) where he can add/delete/edit any type of file and according to that i hav to monitor d space ulitilized by him.

but d problem is the event handlers (written in console). i dont understand what happens when this code is being runned... i dontknow how to use FSW class so that i can monitor d changes user is making in his folder.

please help plz plz ... 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());
}
}
QuestionHow to loop through a ASP.Net Repeater using JQuery Pin
immu524-Jun-10 6:19
immu524-Jun-10 6:19 
AnswerRe: How to loop through a ASP.Net Repeater using JQuery Pin
Not Active24-Jun-10 7:52
mentorNot Active24-Jun-10 7:52 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
immu524-Jun-10 8:05
immu524-Jun-10 8:05 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
Not Active24-Jun-10 8:12
mentorNot Active24-Jun-10 8:12 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
immu524-Jun-10 8:20
immu524-Jun-10 8:20 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
Not Active24-Jun-10 8:35
mentorNot Active24-Jun-10 8:35 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
immu524-Jun-10 8:40
immu524-Jun-10 8:40 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
Not Active24-Jun-10 8:43
mentorNot Active24-Jun-10 8:43 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
immu524-Jun-10 8:49
immu524-Jun-10 8:49 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
Not Active24-Jun-10 8:53
mentorNot Active24-Jun-10 8:53 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
immu524-Jun-10 9:11
immu524-Jun-10 9:11 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
PunkIsNotDead24-Jun-10 11:16
PunkIsNotDead24-Jun-10 11:16 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
Not Active24-Jun-10 16:26
mentorNot Active24-Jun-10 16:26 
GeneralRe: How to loop through a ASP.Net Repeater using JQuery Pin
PunkIsNotDead24-Jun-10 16:39
PunkIsNotDead24-Jun-10 16:39 
QuestionGridview dynamic in edit mode Pin
amina8924-Jun-10 3:36
amina8924-Jun-10 3:36 
AnswerRe: Gridview dynamic in edit mode Pin
Sandeep Mewara24-Jun-10 4:50
mveSandeep Mewara24-Jun-10 4:50 
GeneralRe: Gridview dynamic in edit mode Pin
amina8925-Jun-10 13:54
amina8925-Jun-10 13:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.