'Write'에 해당되는 글 2건

  1. 2012.12.10 [wp8] wp8에서 파일 읽고 쓰기
  2. 2011.09.08 [iphone] plist에 배열 저장/ 읽기
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 동동(이재동)
iPhone App2011. 9. 8. 14:10

먼저 프로젝트에 plist파일을 만들고 이런식으로 추가한다.

201109081408.jpg

추가후

  NSString *path = [[NSBundle mainBundle] bundlePath];

NSString *finalPath = [path stringByAppendingPathComponent:@"LogInElements.plist"];

NSMutableDictionary *namesPlist = [[NSMutableDictionary alloc] initWithContentsOfFile:finalPath];

NSMutableArray* elementNameArray = (NSMutableArray*)[namesPlist objectForKey:@"names"];


이렇게 읽어오면 array 가져올수 있다 편하다!!
Posted by 동동(이재동)