in drive d: , the application shows this info in the lable.text :
<
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Mar 1, 2010, 11:38 AM
First Import
using System.IO;
FileSystemWatcher fsw;
public void WriteLog(string s){
// Get the Exact Location of the textFile
string LogFilePath = Directory.GetParent(Application.ExecutablePath).ToString() + @"\Log.txt";
//Create the StremWriter Object with FileName as Constuctor Argument and the Second Parameter is For Weather Text is Appnded or Not
StreamWriter sw = new StreamWriter(LogFilePath, true);
// Write The Line to TextFile
sw.WriteLine(s);
// Close the Stream Write After Writing
sw.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
fsw = new FileSystemWatcher(@"D:\");
fsw.EnableRaisingEvents = true;
fsw.IncludeSubdirectories = true;
fsw.Deleted += new FileSystemEventHandler(FileDeleted);
}
// Procedure to do When File is deleted
public void FileDeleted(Object Sender, FileSystemEventArgs e)
{
WriteLog("Deleted File :" + e.FullPath);
}