c# - 在 xamarin ios 中预加载数据库

标签 c# ios .net xamarin

我在数据库上遇到错误(名称数据库在当前上下文中不存在),我应该使用哪个 namespace 来导入它? (以下http://developer.xamarin.com/guides/cross-platform/application_fundamentals/data/part_5_using_data_in_an_app/)

if (!File.Exists (Database.DatabaseFilePath))
    File.Copy (seedFile, Database.DatabaseFilePath);

最佳答案

我认为这是文档中的拼写错误。如果您查看本文中链接的高级项目的解决方案,您会发现 DatabaseFilePath 只是包含数据库路径的帮助器类上的静态字段。

在 iOS 中,您可以使用如下方式构建路径:

string dbPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "mydbfile.sqlite");

if (!File.Exists (dbPath))
    File.Copy (seedFile, dbPath);

关于c# - 在 xamarin ios 中预加载数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26457027/

相关文章:

c# - Windows Universal App,无法将所有必需的包添加到项目

c# - LINQ 到 SQL : Reusing DataContext

ios - Error Domain=NSCocoaErrorDomain Code=3840 在Swift5中解析JsonString时

ios - Swift - 从 BviewController 调用 AviewController 方法

c# - 根据目录结构重新组织命名空间

c# - 在linq循环中获取以前的值?

c# - 如何在 Outlook 中添加新选项卡。使用 Visual Studio 2013 进行 Outlook 插件/插件开发

iphone - UITableView tableFooterView 没有出现

asp.net - 安装 .net 4.5 自定义表单后,身份验证中断

c# - .NET 核心 Entity Framework - 转义 "@"字符