Windows Phone 82012.12.10 12:35

 

일단 저장부터 ㅋ

private async Task FileSave(MemoryStream stream)
     {
         IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
         IStorageFile storageFile = await applicationFolder.CreateFileAsync(Const.LocalPlaylistFileName, CreationCollisionOption.ReplaceExisting);
         using (Stream fileStream = await storageFile.OpenStreamForWriteAsync())
         {                
             stream.Seek(0, SeekOrigin.Begin);
             await stream.CopyToAsync(fileStream);
             await fileStream.FlushAsync();
             stream.Dispose();
         }

 

로드하는부분

public async Task LoadAlbums()
       {
         
           IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
 
           IStorageFile storageFile = await applicationFolder.GetFileAsync(Const.LocalPlaylistFileName);
 
           IRandomAccessStream accessStream = await storageFile.OpenReadAsync();
 
           using (Stream stream = accessStream.AsStreamForRead((int)accessStream.Size))
           {
               var o = _serializer.ReadObject(stream);
               LocalPlaylist = o as ObservableCollection<LocalMyAlbum>;
           }
       }

 

일단 윈7이랑 조금 달라졌다.

 

참조한곳이랑은 약간 다르게 구현~

 

참고한곳 : http://dotnetapp.com/blog/2012/08/02/windows-phone-8-shared-core-with-windows-8-file-io/

Posted by 동동(이재동)