簡體   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