Converter Error

2 posts, 0 answers
  1. Randy
    Randy avatar
    72 posts
    Member since:
    Jan 2009

    Posted 04 Aug 2011 Link to this post

    Thanks for the Converter, it normally works great. I found a function that can crash it though and wanted to let you know.

    The while line does a variable assignment and then checks to see if it is null. Although correct in C#, it isn't very pretty code.

    Thanks Again
    Randy

    private string LoadData(string fileName)        
    {            
      string data = String.Empty;            
      using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {                
        using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Open, isf)) {                    
          using (StreamReader sr = new StreamReader(isfs)) {                        
            string lineOfData = String.Empty;                        
            while ((lineOfData = sr.ReadLine()) != null)                            
              data += lineOfData;                    
            }                
          }            
        }            
      return data;        
    }

  2. Todd
    Admin
    Todd avatar
    66 posts

    Posted 05 Aug 2011 Link to this post

    Hi Randy,

    Thanks for the feedback and code sample. We'll try to use this to help improve the handling of this scenario. Otherwise, we're glad you find the Code Converter useful!

    -Todd

Back to Top