[Ironpython-users] unblocking a file in ironpython

Stéphane Lozier stephane.lozier at gmail.com
Fri Jul 1 12:13:10 EDT 2016


Basically what you're trying to do is get rid of the Zone.Identifier
alternate stream of the file. You can see these from the command prompt
using the dir /R command (windows 7 or later?).

I've deleted these before using C# and PInvoke. The file delete methods of
.NET don't let you delete alternate streams which is why I had to PInvoke.
Not sure how this would translate to IronPython...
private static class NativeMethods
{
    [DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    internal static extern bool DeleteFile(string name);
}

private static bool DeleteZoneIdentifier(string filename) =>
NativeMethods.DeleteFile(filename + ":Zone.Identifier");

You can also do it in Powershell using the Unblock-File command (not sure
in what version this was introduced).

I guess you could also use the Streams utility from the command line (
https://technet.microsoft.com/en-us/sysinternals/bb897440.aspx)

On 2016-06-29 9:18 PM, Djordje Spasic via Ironpython-users wrote:

Hello,

Is it possible to unblock a downloaded file (.zip for example) with
ironpython 2.7?
If not, can this be done by invoking the windows command prompt and doing
it inside of it? Which Windows version would this require?

Thank you for the reply,

Kind regards,
Djordje Spasic



_______________________________________________
Ironpython-users mailing
listIronpython-users at python.orghttps://mail.python.org/mailman/listinfo/ironpython-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20160701/5c9cf6e0/attachment.html>


More information about the Ironpython-users mailing list