在Windows 8 Metro应用程序中打开extern SQLite数据库? [英] Open extern SQLite-Database in a Windows 8 Metro-App?

查看:228
本文介绍了在Windows 8 Metro应用程序中打开extern SQLite数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Sqlite for Windows Runtime和sqlite-net(正如 http://timheuer.com/blog/archive/2012/08/07/updated-how-to-using-sqlite-from- windows-store-apps.aspx )来开发一个Windows 8 Metro应用程序,只是。如果我想在程序目录中打开一个数据库没有问题:

I use the "Sqlite for Windows Runtime" and sqlite-net (just as described at http://timheuer.com/blog/archive/2012/08/07/updated-how-to-using-sqlite-from-windows-store-apps.aspx) to develop a Windows 8 Metro-App, just . If I want to open a Database at the Program-Directory is no problem:

var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
using (var db = new SQLite.SQLiteConnection(dbPath)) {
  ...
}

但是当我想像这样使用一个extern路径:

But when I want to use an extern Path like this:

var dbPath = "C:\\Users\\xxxxxx\\db.sqlite";

,则会出现无法打开数据库文件错误。为什么?这里我使用C#,通常我使用C + +,但对于这个问题,我相信它没有关系;)

then an error occurs with "Cannot open database file". Why? Here I am using C#, normally I use C++, but for this problem I am sure it doesn't matter ;)

推荐答案

您不能在文件系统上选择任意文件。有关详情,请参见此处

You cannot select arbitrary files on the file system. See here for details.

默认情况下,您可以访问以下位置:

By default you can access these locations:


  • 应用程序安装目录

  • 应用程序数据位置

  • 用户的下载文件夹


此外,您的应用程序可以访问默认情况下连接的
设备上的一些文件。如果您的应用使用自动播放设备扩展启动当用户将设备
像照相机或USB闪盘驱动器一样连接到他们的系统时自动。您的应用程序
可以访问的文件限于通过
指定的特定文件类型文件类型在应用程序清单中的关联声明。当然,
也可以通过
调用文件选择器来访问可移动设备上的文件和文件夹(使用 FileOpenPicker FolderPicker )和
,让用户选择要访问的应用程序的文件和文件夹。了解
如何在快速入门:使用文件选择器访问文件中使用文件选择器。

Additionally, your app can access some of the files on connected devices by default. This is an option if your app uses the AutoPlay Device extension to launch automatically when users connect a device, like a camera or USB thumb drive, to their system. The files your app can access are limited to specific file types that are specified via File Type Association declarations in your app manifest. Of course, you can also gain access to files and folders on a removable device by calling the file picker (using FileOpenPicker and FolderPicker) and letting the user pick files and folders for your app to access. Learn how to use the file picker in Quickstart: Accessing files with file pickers.

如果您宣告了正确的功能,您也可以访问:

If you have the right capabilities declared you can also access:

  • Documents Library
  • Music Library
  • Picture Library
  • Videos Library
  • Homegroup Library
  • Removable devices
  • Media server devices (DLNA)
  • Universal Naming Convention (UNC) folders

需要结合以下功能。
家庭和工作网络功能:

A combination of the following capabilities is needed. The home and work networks capability:

PrivateNetworkClientServer

至少有一个互联网和公共网络功能:

And at least one internet and public networks capability:

InternetClient InternetClientServer

并且,如果适用,域凭据功能:

And, if applicable, the domain credentials capability:

EnterpriseAuthentication

注意您必须将文件类型关联添加到您的应用清单,声明特定文件类型您的应用程式可以在这个位置存取。

Note You must add File Type Associations to your app manifest that declare specific file types that your app can access in this location.

这篇关于在Windows 8 Metro应用程序中打开extern SQLite数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆