So i have a method that searches for specific file types and moves them into a folder, i want it to exclude some files. Currently having it exclude by file name, my question is how do i exclude by md5 hash in case the excluded files are renamed.
List<string> DeskTopFiles
= Directory.GetFiles(filepath, "*.exe*", SearchOption.AllDirectories)
.ToList();
foreach (string file in DeskTopFiles)
{
if (Path.GetFileName(file).ToLower() != "Whatever.exe")
FileInfo mFile = new FileInfo(file);
if (new FileInfo(d + "\\FileHolder\\" + mFile.Name).Exists == false)
mFile.MoveTo(d + "\\FileHolder\\" + mFile.Name);
}
}
So this is the part im trying to get it to just check md5
if (Path.GetFileName(file).ToLower() != "Whatever.exe")
Edit: guess i have to check the md5 of my exe, so how would i go about stopping it from moving itself if its run from the desktop. Currently have it by != name.exe but i want it by md5 hash