C:\Data\Users\DefApps\AppData\{APPID}\Local\shared\transfers\title=null3rd%20Prototype%20feat.%20Meg%20&%20Dia%20-%20Monster%20(Extended%20Mix%20Edit).mp3
这是打印transfer文件夹中文件的输出,如下所示。
string root = ApplicationData.Current.LocalFolder.Path;
StorageFolder localRoot = await StorageFolder.GetFolderFromPathAsync(root + @"\shared\transfers\");
IReadOnlyList<StorageFile> files;
files = await localRoot.GetFilesAsync(CommonFileQuery.DefaultQuery);
for (int l = 0; l < files.Count; l++)
{
System.Diagnostics.Debug.WriteLine(files[l].Path);
}
然后我尝试在下载完成后将文件移动/复制到根文件夹。
这是移动/复制的文件。
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
var folder = ApplicationData.Current.LocalFolder;
if (isoStore.FileExists(App.ViewModel.DownloadQueue.ElementAt(i).FileName))
{
isoStore.DeleteFile(App.ViewModel.DownloadQueue.ElementAt(i).FileName);
}
try
{
if (isoStore.FileExists("/shared/transfers/" + App.ViewModel.DownloadQueue.ElementAt(i).FileName))
{
isoStore.CopyFile("/shared/transfers/" + App.ViewModel.DownloadQueue.ElementAt(i).FileName, App.ViewModel.DownloadQueue.ElementAt(i).FileName);
}
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
}
isoStore.CopyFile()方法永远不会执行,因为isoStore说该文件不存在!
答案 0 :(得分:1)
将文件存储到IsolatedStorage时,是否确保正确编码了文件路径?看起来文件路径中有空格,这在读写时可能会出现问题。