locked
Serializer.ReadObject() not reading second time. RRS feed

  • Question

  • 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

    Tuesday, January 28, 2014 2:23 PM

All replies

  • have a sample project?

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, January 28, 2014 10:21 PM