2
Hello I am making a software capable of scanning certain Windows files, where in it I leave filtered certain types of extensions, however, by placing to scan the following access message denied in certain folders.
The code would be as follows:
DirectoryInfo dir_Local = new DirectoryInfo(tb_UnidadeHD.Text);
string[] extensao = new string[] { "*.WsF", "*.lnk", "*.vbs", "*.vbe", "*.js", "*.com" };
string[] dir_Info = Directory.GetFiles(tb_UnidadeHD.Text, extensao.ToString(), SearchOption.AllDirectories); ;
try
{
foreach (string procura in dir_Info)
{
lb_Arquivos.Text = string.Format("Escaneando: {0}", procura);
string result = ScanForVirus(procura);
if (!dir_Local.Exists)
MessageBox.Show(string.Format("Diretório de origem não existe ou não pôde ser encontrado: {0}", dir_Local), "AlegoTools", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
{
if (result != string.Empty)
listBox_Files.Items.Add(result);
else
MessageBox.Show(string.Format("Não foi encontrado nenhum vírus em {0}", dir_Local), "AlegoTools", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch { }
If you can give me a light, because I tried other means but without success, it simply can not scan certain parts of windows, even being as admin, shows as if it is without access by the program, and it is configured to run as administrator
Put a
catch
empty is the last thing you should do. You didn’t post the message. I need to leave, then I see if you can answer.– Maniero
"of the following access message denied in certain folders." Did you ever notice the debug error? in my reply I am deducing that it is the exception Unauthorizedaccessexception
– stringnome
The question would not be the empty catch, because I already used the exception of Unauthorizedaccessexception and the error would be the same.
– SNOT