0

If i download 1 file from Internet, the file will blocked as below Image: enter image description here

I want set this attribute from my tool.

In dotnet: can i set this attribute?

Or exist command line to set this attribute?

Thank you.

Community
  • 1
  • 1
D T
  • 3,522
  • 7
  • 45
  • 89
  • 1
    [This question](https://stackoverflow.com/questions/6374673) asks about *unblocking* the file. (This attribute is stored in the `Zone.Identifier` alternate data stream.) – Jonathon Reinhart Jun 15 '20 at 04:01

1 Answers1

0

Thank you Jonathon Reinhart . I used PersistZoneIdentifier and can blocked file:

 public enum URLZONE : uint
        {
            URLZONE_LOCAL_MACHINE = 0,
            URLZONE_INTRANET = 1,
            URLZONE_TRUSTED = 2,
            URLZONE_INTERNET = 3,
            URLZONE_UNTRUSTED = 4,
        }

        [ComImport]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        [Guid("cd45f185-1b21-48e2-967b-ead743a8914e")]
        public interface IZoneIdentifier
        {
            URLZONE GetId();
            void SetId(URLZONE zone);
            void Remove();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            String file = "D:\\Test\\test.zip";
            object persistZoneId =  Activator.CreateInstance(Type.GetTypeFromCLSID(Guid.Parse("0968e258-16c7-4dba-aa86-462dd61e31a3")));
            IZoneIdentifier zoneIdentifier = (IZoneIdentifier)persistZoneId;
            IPersistFile persisteFile = (IPersistFile)persistZoneId;
            zoneIdentifier.SetId(URLZONE.URLZONE_INTERNET);
            persisteFile.Save(file, false);
        } 

Refer: Setting Windows file security

D T
  • 3,522
  • 7
  • 45
  • 89