.net - SQLite:BLOB用于存储大文件吗?

标签 .net vb.net sqlite large-files

我想在sqlite数据库中存储大文件(超过100mb)。我注意到,它的性能不好。
我必须将文件存储在本地文件夹中,还是必须重写代码?

       Shared Sub BlobToFile(ByVal Blob As Byte(), ByVal file As String)
        Dim MyData() As Byte = Blob
        Dim K As Long
        K = UBound(MyData)
        Dim fs As New FileStream _
         (file, FileMode.Create, _
          FileAccess.Write)
        fs.Write(MyData, 0, K)
        fs.Close()
        MyData = Nothing
        K = Nothing
    End Sub
    Shared Function FileToBlob(ByVal Filepath As String) As Byte()
        Dim fs As New FileStream _
     (Filepath, FileMode.Open, _
      FileAccess.Read)
        Dim MyData(fs.Length) As Byte
        fs.Read(MyData, 0, fs.Length)
        fs.Close()
        Return MyData
    End Function
'Then I Do this:
Dim x As New Sqliteparameter With {.Name ="@file", .value=Filetoblob("C:\Testfile.zip"), .DbType.Binary}
Dim y As New SqliteCommand With {.Commandtext = "INSERT INTO FILES(File) Values(@file);"}
y.Parameters.add(x)
y.Executenonquery()


谢谢

最佳答案

通常最好的做法是不要在数据库中存储大文件,除非有支持,例如mssql服务器。我建议您仅考虑将文件的位置存储在数据库中,并将文件存储在某种文件系统中。

关于.net - SQLite:BLOB用于存储大文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10268217/

相关文章:

c# - 正则表达式匹配整个单词和标点符号

vb.net - 如何通过网络在两个 VB.NET 应用程序之间进行通信

javascript - 有条件地显示和隐藏从数据库生成的选择输入选项?

.net - 为数据表中的所有行设置值,无需 for 循环

c# - Azure 移动服务 PullAsync() 未填充同步表

sqlite - SQLite:如何将行值增加+1?

.net - 在反编译的 ArraySegment 中抛出 null

c# - Entity Framework Brainmush Kerfuffle 壮观

c# - SqlDataReader 显示 InvalidCastException(C# Windows 窗体)

android - SQLite 查询性能