我想做的是类似于以下内容:
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
}
我不打算写入内存数据库,但在连接到它之前,我需要能够在我的程序的内存中对文件做一些事情。