示例#1
0
 public SQLiteConnection GetConnection()
 {
     if (this.conn == null)
     {
         this.conn = new SQLiteConnection(Repository.GetDbPath());
     }
     return(this.conn);
 }
示例#2
0
        protected void CheckDatabaseFile()
        {
            string dbPath = Repository.GetDbPath();

            if (!File.Exists(dbPath))
            {
                using (BinaryReader br = new BinaryReader(Assets.Open(Repository.DB_NAME)))
                {
                    using (BinaryWriter bw = new BinaryWriter(new FileStream(dbPath, FileMode.Create)))
                    {
                        byte[] buffer = new byte[2048];
                        int    len    = 0;
                        while ((len = br.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            bw.Write(buffer, 0, len);
                        }
                    }
                }
            }
        }