Last active
January 20, 2017 14:57
-
-
Save judge2020/80b18fee49f979cdb5f8b5a52f0d5d08 to your computer and use it in GitHub Desktop.
unblock file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FileUnblocker { | |
[DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
public static extern bool DeleteFile(string name ); | |
public bool Unblock(string fileName) { | |
return DeleteFile(fileName+ ":Zone.Identifier"); | |
} | |
} | |
; HDT code | |
foreach(var file in PluginDir) { | |
FileUnblocker.Unblock(file.FullPath); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment