In this question I have searched for a simple solution to unblock files.
Thanks to all the comments and answer, I have found a simple solution by PInvoking DeleteFile
I made a small refinement to the code. You can now just pass your startup path to the UnblockPath() function and it will automatically unblock all of the files and sub directory files for your executable. It could be refined further to only search for .exe, .dll, etc.
[DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteFile(string name);
public static void UnblockPath(string path)
{
string[] files = System.IO.Directory.GetFiles(path);
string[] dirs = System.IO.Directory.GetDirectories(path);
foreach (string file in files)
{
UnblockFile(file);
}
foreach (string dir in dirs)
{
UnblockPath(dir);
}
}
public static bool UnblockFile(string fileName)
{
return DeleteFile(fileName + ":Zone.Identifier");
}