Advertisement
Guest User

Untitled

a guest
May 13th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1.       private void LoadSuggestedAnswer(string fileName)
  2.         {
  3.            
  4.             try
  5.             {
  6.                 string line;
  7.  
  8.                 StreamReader iterationReader = new StreamReader("iterationsLearned.txt", Encoding.Default);
  9.                 int innerIteration = Convert.ToInt32(iterationReader.ReadLine());
  10.  
  11.                 StreamReader theReader = new StreamReader(fileName, Encoding.Default);
  12.  
  13.                 using (theReader)
  14.                 {
  15.                     do
  16.                     {
  17.                         line = theReader.ReadLine();
  18.  
  19.                         if (line != "9")
  20.                         {
  21.                             for (int i = 0; i < line.Length; i++)
  22.                             {
  23.                                 suggedtedAnswer[i] = Convert.ToInt32(line[i]);
  24.                             }
  25.                            
  26.                         }
  27.                         else if(line == "9")
  28.                         {
  29.                             innerIteration++;
  30.                             string pathIterations = "iterationsLearned.txt";
  31.                             File.WriteAllText(pathIterations, innerIteration.ToString());
  32.                            
  33.  
  34.                             Debug.Log("ITERATION:" + innerIteration.ToString());
  35.                         }
  36.                         else
  37.                         {
  38.  
  39.                         }
  40.                     }
  41.                     while (line != null);
  42.                     theReader.Close();
  43.                 }
  44.             }
  45.             catch (Exception e)
  46.             {
  47.                 Debug.Log(e.Message);
  48.             }
  49.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement