Tuesday, January 28, 2014

Serializer.ReadObject() not reading second time.

Hello,


I am reading file from my local folder, first time it is working fine, but second time it give me error like "Index was outside the bounds of the array."


code sample is here..



public static async Task<T> LoadTable<T>(string tableName)
{
try
{
StorageFile file = await ApplicationData.Current.
LocalFolder.GetFileAsync(tableName);
Stream stream = await file.OpenStreamForReadAsync();
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
T table = (T)serializer.ReadObject(stream);
stream.Dispose();
return table;

}
catch (Exception)
{
return default(T);
}
}

error:





Jitendra Jadav


No comments:

Post a Comment