DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Acceder A La Fecha En La Que Una Foto Fue Tomada En VB .NET

10.30.2006
| 3405 views |
  • submit to reddit
        //Función a la que se le pasa el archivo jpg o jpge y devuelve la fecha en la que fue tomada

    Public Function ObtieneFecha(ByVal RutaArchivo As String) As Date

        Dim image As New Bitmap(RutaArchivo)
        Dim propItems As System.Drawing.Imaging.PropertyItem() = image.PropertyItems

        Dim encoding As New System.Text.ASCIIEncoding

        For i As Integer = propItems.GetLowerBound(0) To propItems.GetUpperBound(0)
            If propItems(i).Id.ToString = "36868" Then
                Dim strAux1() As String = Split(encoding.GetString(propItems(i).Value), " ")
                Dim strAux2() As String = Split(strAux1(0), ":")
                Dim strAux3() As String = Split(strAux1(1), ":")
                Return CDate(strAux2(0) & "/" & strAux2(1) & "/" & strAux2(2) & " " & strAux3(0) & ":" & strAux3(1) & ":" & strAux3(2))
            End If
        Next
        image.Dispose()
    End Function