在Windows Iot的外部驱动器上创建,编写,读取SQLite DB

时间:2018-06-11 10:14:10

标签: c# sqlite file-permissions windows-iot-core-10

我有一台Raspberyy Pi3设备。

我正在使用VS2017 c#。

我正在使用Windows Iot Core。

我已将USB驱动器连接到我的Pi盒。

我正在尝试打开/创建sqlite db。

我得不到错误。

如果我将数据库路径切换到SD卡,它就能正常工作。

那么,是否有可能将我的.db文件放在外部USB驱动器上以及如何使用?

由于

我的代码:

public static async Task<string> GetUsbPath()
{
    var removableDevices = KnownFolders.RemovableDevices;
    var externalDrives = await removableDevices.GetFoldersAsync();
    var usbDrive = externalDrives.FirstOrDefault(e => e.DisplayName.Contains("Data"));
    return usbDrive != null ? usbDrive.Path : string.Empty;
}

n.b 这将返回&#34; d:\&#34;

调用代码:

var path = Path.Combine(GetUsbPath().Result, "db.db");
Connector = new SQLiteConnection(new SQLitePlatformWinRT(), path);

这将返回&#39; sqlite couldopen&#39;错误...

n.b。 在我的package.asppxmanifest文件中,我启用了“可移动存储”#。

0 个答案:

没有答案