title: How to save data into a format that can be called upon later on
body: <p>I have been working on reading a text file and organizing the text into blocks for each item. I need help on figuring out a way of which the data can be saved and called upon during the use of the program. I am trying to have the output as a data grid view. I am not sure how to approach this. I am thinking I could create a data table for each new block, but I don't know how to do this.</p>
  
  <p>My code so far:</p>
  
  <pre><code>public void findBlocks()
      {
          String fileName = "Drops.de";
          StreamReader streamReader = new StreamReader(fileName);
          String npcName;
          string npcID;
          string itemID;
          string itemAmount;
          string itemRarity;
          string itemName;
  
          while(!streamReader.EndOfStream){
              string line = streamReader.ReadLine();
              //start of block
              if(line.StartsWith("[")){
                  npcName = line.TrimStart('[');
                  npcName = npcName.TrimEnd(']');
                  while(!line.StartsWith("[/")){
                      line = streamReader.ReadLine();
                      String[] s = line.Split(' ');
                      npcID = (s[0]);
                      itemName = (s[1]);
                      itemID = (s[2]);
                      itemAmount = (s[3]);
                      itemRarity = (s[4]);
                      DataTable dt = new DataTable();
                      DataGridViewRow dgv = new DataGridViewRow();
  
                      DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
                      row.Cells[0].Value = itemName;
                      row.Cells[1].Value = itemID;
                      row.Cells[2].Value = itemAmount;
                      row.Cells[3].Value = itemRarity;
                      dataGridView1.Rows.Add(row);
                      dataGridView1.Refresh();
                      line = streamReader.ReadLine();
                 //MessageBox.Show(npcName);
                  }
              }
          }
      }
  
      private void button2_Click(object sender, EventArgs e)
      {
          search();
      }
  
      public void loadItemList(string file)
      {
          String fileName = file;
          StreamReader streamReader = new StreamReader(fileName);
  
          while (!streamReader.EndOfStream)
          {
              string currentLine = streamReader.ReadLine();
              string s;
              String id;
              String itemName = "";
  
              if (currentLine.Contains("item"))
              {
                  s = currentLine.TrimStart('i', 't', 'e', 'm', ' ', '=', ' ');
                  id = s.Split('.')[0];
                  itemName = id.Split('\t')[1];
                  id = id.Split('\t')[0];
  
                  listBox1.Items.Add(itemName + " " + id);
  
              }
              else
              {
                  streamReader.ReadLine();
              }
  
          }
          streamReader.Close();
      }
  </code></pre>
  
  <p>This is an example of the text file that I am trying to sort:</p>
  
  <pre><code>[item1]
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  [/item1]
  [item2]
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  [/item2]
  [item3]
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  2550 coins 995 200000 7
  [/item3]
  </code></pre>
  
  <p>etc..</p>
  
  <p>Any and all help would be greatly appreciated :)</p>