일단 저장부터 ㅋ
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/
'Windows Phone 8' 카테고리의 다른 글
the activation request failed with error 가 뜨면서 실행이 안될때 (0) | 2013.05.07 |
---|---|
[wp8] Navigation Back Back하기 (0) | 2013.03.15 |
[WP8] List Reserve 거꾸로 정렬 (0) | 2013.03.04 |
[wp8] ViewModel에서 Applicaionbar를 변경해보자. (0) | 2012.12.06 |
[wp8] Generic 형식 전역(global)에서 사용하기 (0) | 2012.10.18 |