ariez

ariez

  • NA
  • 34
  • 0

FileSystemWatcher

Jun 30 2010 5:22 AM

m using FileSystemWatcher, i want to get the size of a file present in my folder. whereas i can find the size of whole folder but not of a file inside that folder. m using fileinfo.lenght to get the size of the file, for this fileinfo.exists property should be true but it is false i dont knw y? even if file already exists.
m using Filesystemwatcher in windows application where as my main application is a web based(ASP.NET). now what i want to achieve is that whenever user creates a new file or copy the existing file in that folder, the application should get the size of the newly created file or copied file and check with the remaining space of that folder because user is given only a limited space (letsay 1 or 2 GB)
eg when u save anything in ur PC the space of the hard disk is decreased. i want to do exactly the same thing that when user creates any file and wishes to save it ,at that time the space must be checked.
people with brains plz come fwd to help me in this regard...THANX
 
 private void filewatcher_Changed(object sender, FileSystemEventArgs e)
        {
            string path = e.FullPath;
            int index = path.LastIndexOf("\\");
            string filename = path.Substring(index + 1);
            FileInfo fi = new FileInfo(filename);
            string a=filename.Length.ToString();
            txtLog.Text += e.ChangeType + ": " + e.FullPath + "\r\n";
            txtLog.Focus();
            txtLog.Select(txtLog.TextLength, 0);
            txtLog.ScrollToCaret();
        }
private void Monitor_button (object sender, EventArgs e)
        {
            fileWatcher.Path = @txtPath.Text;
            fileWatcher.Filter = txtFilter.Text;
            fileWatcher.IncludeSubdirectories = chkSubdirectories.Checked;
            fileWatcher.EnableRaisingEvents = true;
          
        }

Answers (2)