3

Had an interesting problem where, for some reason, when our customer deployed our application onto their computer (file copy deployment), Windows blocked all of the files. This can be detected by right clicking on the file, going to properties and then there is button entitled "Unblock".

I believe this is caused when the files are transferred onto the computer from an unknown source such as the internet.

Is there a way I could detect that the files are blocked in C#? I am not sure if this "operating system block" sets specific file attributes or something. Also could the file be unblocked in someway?

Note: I am aware of the paradox that the .exe file used to check if files are blocked may itself be blocked but I am hoping my user can at least unblock one file from the install set!

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Remotec
  • 10,304
  • 25
  • 105
  • 147

1 Answers1

2

In Windows, this feature is implemented using an Alternative Data Stream with a Zone Identifier. (see Hanselman's explanation here). You just need to detect a Zone Identifier of 3 or 4, which indicate the file is blocked.

To interact with the data stream, you can use the Windows API CreateFile function and pass in :Zone.Identifier with the filename (as shown in this question) or, better yet, just use this library off of CodeProject to do it for you.

LWC
  • 1,084
  • 1
  • 10
  • 28
Tim Copenhaver
  • 3,282
  • 13
  • 18