你好我有这个代码
private async Task SaveImageToIsolatedStorage(Stream stream)
{
StorageFolder Datafolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Data");
StorageFolder subfolder1 = await Datafolder.GetFolderAsync("subfolder1");
StorageFolder subfolder2 = await subfolder1 .GetFolderAsync("subfolder2");
StorageFile file = await subfolder2.CreateFileAsync("test.jpg", CreationCollisionOption.ReplaceExisting);
using (Stream current = await file.OpenStreamForWriteAsync())
{
await stream.CopyToAsync(current);
}
}
如果我直接使用StorageFolder.GetFolderFromPathAsync(" Data \ subfolder1 \ subfolder2")收到错误
{System.IO.FileNotFoundException:系统找不到指定的文件
怎么样?
答案 0 :(得分:1)
根据msdn上的帖子,你需要使用双斜杠:
StorageFolder.GetFolderFromPathAsync("Data\\subfolder1\\subfolder2")
答案 1 :(得分:0)
好的,可以使用这段代码
StorageFolder folder= await ApplicationData.Current.LocalFolder.GetFolderAsync("Data\\subfolder\\subfolder1");