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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Mar 1, 2010, 6:38 AM EST
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);
}