Tuesday, February 2, 2010

Get or Fetch and delete data from recyclebin in windows XP

//posted by anil jain

List myList = new List();

string sOsVersion = System.Environment.OSVersion.ToString();
Environment.GetEnvironmentVariable("windir", EnvironmentVariableTarget.Machine);
string[] sDriveLetter = Environment.GetLogicalDrives();

if (sOsVersion.IndexOf("5.1.2") > 0) //For Windows XP
{
for (int j = 0; j < sDriveLetter.Count(); j++)
{
try
{
string[] Files = Directory.GetFiles(sDriveLetter.ElementAt(j) + "Recycler\\", "*", SearchOption.AllDirectories);

for (int i = 0; i < Files.Count(); i++)
{
try
{
//File.Delete(Files.ElementAt(i));
myList.Add(Files.ElementAt(i));
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}

No comments:

Post a Comment