繁体   English   中英

Windows Phone 8中不允许在IsolatedStorage中移动文件

[英]Moving File in IsolatedStorage Not Permitted Windows Phone 8

我有一个文件的后台下载,这是代码:

LiveOperationResult downloadResult = await client.BackgroundDownloadAsync(id, new Uri("/shared/transfers/MyDB.sdf", UriKind.Relative));

然后我必须使用以下代码将下载的文件从共享/传输文件夹复制到isolatedStorage的根文件夹。

  using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        storage.MoveFile("/shared/transfers/MyDB.sdf", "MyDB.sdf");                            
                    }

当执行指令storage.MoveFile(...)时,我遇到了“不允许的孤立存储操作”异常。 我不明白原因。 提前致谢。

在移动文件之前,请确保目标文件不存在。

if (storage.FileExists("MyDB.sdf"))
{
    storage.DeleteFile("MyDB.sdf");
}
storage.MoveFile("/shared/transfers/MyDB.sdf", "MyDB.sdf");

还要确保源文件流不再打开。

对不起,我迟到了。

但是对于面临相同问题的任何人,请尝试以下操作

而不是移动到根文件夹,而是将其移动到roor内部的其他文件夹。 当我在隔离存储的根文件夹上创建文件时,我在Windows Phone 8上遇到了同样的问题。 由于某种原因,我的设备没有显示任何问题。 当我的应用程序上线时,我就知道了。 很难找到。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM