I want to list all files in drive and i m also trying this code in c#. but i get unaurthorizedfileaccess exception. plzz give me right solution so i can go ahead in my work....
try
{
var files = new List<string>(Directory.GetFiles("E:\", "*.*", SearchOption.AllDirectories));
Method(files);
}
catch(Exception e)
{
Console.WriteLine(e);
}
static void Method(List<string> files)
{
foreach (string file in files)
{
Console.WriteLine(file);
}
Console.WriteLine(files.Count);
}