I want to be able to scan all logical drives and get all exe/dll files, in order to output all .net types/classes in all assemblies on the current windows machine regardless of the OS version. I run wINDOWS 7, I have admin rights (checking it in code) and still get access denied for C:\Documents and Settings
What I'm doing wrong?
bool aaa = AmIAdmin();
GetAllNet();
static Dictionary<string, object> GetAllNet()
{
List<string> binaries = new List<string>();
string[] drives = Directory.GetLogicalDrives();
foreach (string dir in drives)
{
binaries.AddRange(Directory.GetFiles(dir, "*.dll", SearchOption.AllDirectories));
binaries.AddRange(Directory.GetFiles(dir, "*.exe", SearchOption.AllDirectories));
}
return null;
}
static bool AmIAdmin()
{
return new WindowsPrincipal(WindowsIdentity.GetCurrent())
.IsInRole(WindowsBuiltInRole.Administrator);
}