gpt4 book ai didi

c# - 在 Windows 8 Metro-App 中打开 extern SQLite-Database?

转载 作者:太空宇宙 更新时间:2023-11-04 15:24:26 25 4
gpt4 key购买 nike

我使用“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-App,仅 .如果我想在程序目录中打开数据库没问题:

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

但是当我想使用这样的外部路径时:

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

然后发生“无法打开数据库文件”错误。为什么?这里我使用的是 C#,通常我使用的是 C++,但是对于这个问题,我相信这无关紧要;)

最佳答案

您不能选择文件系统上的任意文件。参见 here了解详情。

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

  • 应用安装目录
  • 应用程序数据位置
  • 用户的下载文件夹

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.

如果您声明了正确的能力,您还可以访问:

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.

关于c# - 在 Windows 8 Metro-App 中打开 extern SQLite-Database?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12220751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com