无法在C#metro应用程序中的所需位置保存文件

时间:2012-12-11 11:50:59

标签: c# microsoft-metro app.xaml

我正在开发一个使用文件输入和输出的metro应用程序。我用来保存文件的代码是

StorageFolder appfolder = await Windows.Storage.KnownFolders.DocumentsLibrary.CreateFolderAsync("Appdata.abc", Windows.Storage.CreationCollisionOption.ReplaceExisting);
StorageFile file = await Windows.Storage.KnownFolders.DocumentsLibrary.CreateFileAsync(DateFileName + ".uvraj", Windows.Storage.CreationCollisionOption.ReplaceExisting);

现在如何在我创建的文件夹中创建/保存文件?

1 个答案:

答案 0 :(得分:1)

调用appfolder对象上的方法,而不是您正在使用的KnownFolder

像这样:

StorageFolder appfolder = await Windows.Storage.KnownFolders.DocumentsLibrary.CreateFolderAsync("Appdata.abc", Windows.Storage.CreationCollisionOption.ReplaceExisting);
StorageFile file = await appfolder.CreateFileAsync(DateFileName + ".uvraj", Windows.Storage.CreationCollisionOption.ReplaceExisting);