C# 正在写入InstalledLocation文件夹
我的Windows应用商店应用程序无法通过认证,因为我正在写入InstalledLocation文件夹,而不是本地文件夹 我正在将一个现有的SQLite db加载到应用程序中,如果它还不存在的话 下面是我的代码:C# 正在写入InstalledLocation文件夹,c#,windows-store-apps,uwp,C#,Windows Store Apps,Uwp,我的Windows应用商店应用程序无法通过认证,因为我正在写入InstalledLocation文件夹,而不是本地文件夹 我正在将一个现有的SQLite db加载到应用程序中,如果它还不存在的话 下面是我的代码: private static string dbName = "flashcards2015a.db"; private static string dbPath = string.Empty; public MainPage() { this
private static string dbName = "flashcards2015a.db";
private static string dbPath = string.Empty;
public MainPage()
{
this.InitializeComponent();
LoadDataTask();
LoadDecksNames();
}
private async void LoadDataTask()
{
await CreateIfNotExists(dbName);
}
private async Task CreateIfNotExists(string dbName)
{
if (await GetIfFileExistsAsync(dbName) == null)
{
StorageFile seedFile = await StorageFile.GetFileFromPathAsync(Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, dbName));
await seedFile.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder);
}
}
如何将代码更改为本地文件夹以获取db文件?您需要将StorageFile.GetFileFromPathAsync中的路径.CombinWindows.ApplicationModel.Package.Current.InstalledLocation.Path更改为Windows.Storage.ApplicationData.Current.LocalFolder
更多信息:您需要将StorageFile.getfilefrompathsync中的Path.combinewindows.ApplicationModel.Package.Current.InstalledLocation.Path更改为Windows.Storage.ApplicationData.Current.LocalFolder
更多信息:您需要使用StorageFile.GetFileFromApplicationUriAsync() 更多信息:
您需要使用StorageFile.GetFileFromApplicationUriAsync() 更多信息:
你确定这就是问题所在吗?显示的代码不会写入安装位置。它似乎正确地将种子数据库从安装位置复制到本地存储。错误之处在于它没有等待LoadDataTask,因此LoadDecksNames可能在LoadDataTask复制文件之前被调用。在不知道LoadDecksNames是什么的情况下,我不知道它是回到种子还是遇到了其他问题。你确定这就是问题所在吗?显示的代码不会写入安装位置。它似乎正确地将种子数据库从安装位置复制到本地存储。错误之处在于它没有等待LoadDataTask,因此LoadDecksNames可能在LoadDataTask复制文件之前被调用。在不知道LoadDecksNames是什么的情况下,我不知道它是落在种子上还是遇到了其他问题。
var uri = new System.Uri("ms-appx:///images/logo.png");
var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);