2013-05-29 1 views
0

개인 무효 라인 아래이에서 (개체를 보낸 사람, RoutedEventArgs e)에 {데이터베이스 파일 스카이 드라이브에서 오류를 복원

 string id = string.Empty; 
     client.GetCompleted += (obj, args) => 
     { 
      List<object> items = args.Result["data"] as List<object>; 
      foreach (object item in items) 
      { 
       Dictionary<string, object> file = item as Dictionary<string, object>; 
       if (file["name"].ToString() == "Expensemanager.bak") 
       { 
        id = file["id"].ToString(); 
       } 
      } 

      client.DownloadCompleted += (o, a) => 
      { 
       Stream stream = a.Result; 

       using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) 
       {  
         var fileToSave = new IsolatedStorageFileStream("expanseManager.sdf", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, storage); 

         stream.CopyTo(fileToSave); 
         stream.Flush(); 
         stream.Close(); 

       } 
      }; 

      client.DownloadAsync(string.Format("{0}/content", id)); 
     }; 

     client.GetAsync("me/skydrive/files"); 
    } 

오류 ... 작동하지 OnRestoreClicked 격리 된 저장소에서 허용됩니다.

var fileToSave = new IsolatedStorageFileStream ("expanseManager.sdf", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, storage);

답변

0

sdf 파일을 덮어 쓰기 전에 데이터베이스를 닫아야합니다. 당신은 세계 DataContext 참조를 지키고 있다면 당신은 그것을 처분해야합니다. 그 외에는 using 블록 내에 db 상호 작용을 포함 시키십시오.

+0

감사합니다. Alaa :) –