我想要做的是类似于以下内容:
using System.Data.SQLite;
using System.IO;
//My SQLite connection
SQLiteConnection myCon;
public void ReadAndOpenDB(string filename)
{
FileStream fstrm = new FileStream(filename, FileMode.Open);
byte[] buf = new byte[fstrm.Length];
fstrm.Read(buf, 0, (int)fstrm.Length);
MemoryStream mstrm = new MemoryStream(buf);
//Do some things with the memory stream
myCon = new SQLiteConnection(/*attach to my memory stream for reading*/);
myCon.Open();
//Do necessary DB operations
}
我不打算写入内存数据库,但我需要在连接到它之前,在程序中对文件进行一些操作并将其保存在内存中。