I need to check whether a file (with unknown extension) is a valid SQLite database.
My function works fine, but when it fails, the file is still locked after exiting the
To determine if a file is an SQLite database, just check the first 16 bytes of the database header.
from tmighty's comment:
Public Function IsSqliteDB(ByVal uPath As String) As Boolean
Dim bytes(16) As Byte
Using fs As New IO.FileStream(uPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
fs.Read(bytes, 0, 16)
End Using
Dim text As String = System.Text.ASCIIEncoding.ASCII.GetString(bytes)
Return text.Contains("SQLite format")
End Function