Search code examples
c#.net.net-4.0pinvokealternate-data-stream

Unblock File from within .net 4 c#


Is there a possibility to unblock a file that is downloaded from the internet from within a c# program. Surfing the internet I have learned, that the information is written in an alternative stream of a (NTFS) file that contains the current zone information (value 3 is from the internet and is interpreted as blocked).

Is there a managed possiblity to either clear or change the zone information (unblock) of a file or is there a managed copy function that copies the files without the zone information? If not, how can I do with PInvoke but without including a foreign assembly (I'm not allowed to do this in a current project).


Solution

  • It's stored in the :Zone.Identifier stream (more < c:\theapp.exe:Zone.Identifier) you need to use the native IO routines to manipulate them, here is a managed wrapper.