Underc0de

Programación General => C# - VB.NET => Mensaje iniciado por: fudmario en Diciembre 04, 2016, 05:17:08 PM

Título: [VB.NET] ZoneIdentifier Wrapper by fudmario
Publicado por: fudmario en Diciembre 04, 2016, 05:17:08 PM
Una simple implementacion para obtener el ZONE.IDENTIFIER(Windows Zone Identifier File) del archivos.

Ejemplo de Uso:

Código (vbnet) [Seleccionar]

   Using zi As New ZoneIdentifier("D:\Sample.exe")
            If zi.Zone = UrlZone.Internet Then
                zi.Remove
            End If
   End Using



El Proyecto esta disponible para descargar: ZoneIdWrapper (https://github.com/fudmario/ZoneIdWrapper)


Si solo quieren eliminar el ZoneIdentifier, pueden usar la API:

Código (vbnet) [Seleccionar]

<DllImport("kernel32.dll", CharSet:=CharSet.Auto, BestFitMapping:=False, ThrowOnUnmappableChar:=True, SetLastError:=True)>
        Public Shared Function DeleteFile(<MarshalAs(UnmanagedType.LPTStr)> ByVal filepath As String
        ) As <MarshalAs(UnmanagedType.Bool)> Boolean
        End Function


Ejemplo de Uso:

Código (vbnet) [Seleccionar]

<DllImport("kernel32.dll", CharSet:=CharSet.Auto, BestFitMapping:=False, ThrowOnUnmappableChar:=True, SetLastError:=True)>
        Public Shared Function DeleteFile(<MarshalAs(UnmanagedType.LPTStr)> ByVal filepath As String
        ) As <MarshalAs(UnmanagedType.Bool)> Boolean
        End Function
Public Function DeleteZoneIdentifier(ByVal filePath As String) As Boolean
       Return DeleteFile(filePath + ":Zone.Identifier")
End Function