wp8应用程序中的sdf文件

时间:2014-01-03 10:54:39

标签: c# windows-phone-8 sql-server-ce

我正在研究WP8应用程序,并使用sqlite db存储应用程序数据。

我按照http://developer.nokia.com/Community/Wiki/How_to_use_SQLite_in_Windows_Phone链接中的步骤进行操作。

但是当我分析我的项目文件时,我可以看到一个Appname.sdf文件。如何自动创建这个(如果我删除它,它仍然会在我打开解决方案时自动生成)。对此有什么好的解释吗?

1 个答案:

答案 0 :(得分:0)

只需在参考链接http://developer.nokia.com/Community/Wiki/How_to_use_SQLite_in_Windows_Phone

中查看此代码段
using (IsolatedStorageFileStream output = iso.CreateFile(MainPage.DB_PATH))
   {
    // Initialize the buffer.
    byte[] readBuffer = new byte[4096];
    int bytesRead = -1;

   // Copy the file from the installation folder to the local folder. 
   while ((bytesRead = input.Read(readBuffer, 0, readBuffer.Length)) > 0)
      {
    output.Write(readBuffer, 0, bytesRead);
      }
    }

执行“using(IsolatedStorageFileStream output = iso.CreateFile(MainPage.DB_PATH))”时,它会在没有数据的独立存储中创建一个新文件。 这就是为什么你总是在你的应用程序中获得db文件。

相关问题