Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting file type
Message
De
13/02/2009 17:31:12
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Detecting file type
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Web
Divers
Thread ID:
01381670
Message ID:
01381670
Vues:
67
I have this method to detect the file type:
        ' Return the file type
        ' expC1 File name with the full path
        Public Function FileType(ByVal tcFile As String) As String
            Dim lcString As String = ""
            lcString = FileToStr(tcFile)

            If lcString.Length < 4 Then
                Return ""
            End If

            If Left(lcString, 3) = Chr(255) + Chr(232) + Chr(255) Then
                Return "JPG"
            End If

            If Left(lcString, 3) = "GIF" Then
                Return "GIF"
            End If

            If Mid(lcString, 42, 3) = "EMF" Then
                Return "EMF"
            End If

            If Left(lcString, 4) = Chr(215) + Chr(205) + Chr(198) + Chr(154) Then
                Return "WMF"
            End If

            If Left(lcString, 4) = Chr(77) + Chr(77) + Chr(0) + Chr(42) Then
                Return "TIF"
            End If

            If Left(lcString, 4) = Chr(137) + "PNG" Then
                Return "PNG"
            End If

            If Left(lcString, 2) = "BM" Then
                Return "BMP"
            End If

            If Left(lcString, 3) = "CWS" And Asc(Mid(lcString, 4, 1)) < 16 Then
                Return "SWF"
            End If

            If Left(lcString, 3) = "FWS" And Asc(Mid(lcString, 4, 1)) < 16 Then
                Return "SWF"
            End If

            Return ""
        End Function

    End Class
Now, I need to add file type detection for ZIP, XML, DOC, XLS, PDF and TXT. Is there file detection for some of those I could add?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform