I am doing this,when the use When the user logs in
UserInfo CurrentUser = new UserInfo();
CurrentUser.F_Name = CurrentObject.Get<string>("F_Name");
CurrentUser.F_Name = CurrentObject.Get<string>("F_Name");
CurrentUser.L_Name = CurrentObject.Get<string>("L_Name");
CurrentUser.Company_Name =
CurrentUser.Password = CurrentUserPass;
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
StorageFile userdetailsfile = await localFolder.CreateFileAsync("UserInfo", CreationCollisionOption.ReplaceExisting);
IRandomAccessStream raStream = await userdetailsfile.OpenAsync(FileAccessMode.ReadWrite);
using (IOutputStream outStream = raStream.GetOutputStreamAt(0))
{
// Serialize the Session State.
DataContractSerializer serializer = new DataContractSerializer(typeof(UserInfo));
serializer.WriteObject(outStream.AsStreamForWrite(), CurrentUser);
await outStream.FlushAsync();
}
Then In another page, I want to retrieve the file that has the user Info in above code by
public async Task RestoreAsync()
{
StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("UserInfo");
if (file == null) return ;
IRandomAccessStream inStream = await file.OpenReadAsync();
// Deserialize the Session State.
DataContractSerializer serializer = new DataContractSerializer(typeof(UserInfo));
CurrentUser = (UserInfo)serializer.ReadObject(inStream.AsStreamForRead());
inStream.Dispose();
this.DefaultViewModel["FirstName"] = CurrentUser.F_Name;
this.DefaultViewModel["LastName"] = CurrentUser.L_Name;
}