2014-04-06 58 views
0

我有一個文件的後臺下載,這是代碼:在IsolatedStorage移動文件不允許的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(...)我有一個IsolatedStorage Operation Not Permission異常。我不明白原因。提前致謝。

+0

可能BackgroundTransfers仍然使用該文件,因此您無法刪除它。嘗試[刪除傳輸請求](http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh286419(v = vs.105).aspx)完成後 – Romasz

回答

1

確保在移動文件之前目標文件不存在。

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

還要確保源文件流不再打開。

0

對不起,延遲應答。

但任何人誰面臨着同樣的問題,試試這個

而是移動到根文件夾,將其移動到其他文件夾內ROOR。當我在隔離存儲的根文件夾上創建文件時,我在windows phone 8上遇到了同樣的問題。出於某種原因,我的設備沒有顯示任何問題。當我的應用程序上線後,我才知道這件事。這很難找到。

相關問題