title: How to export a row in a DataGridView to a txt file
body: <p>As I can select a row in a DataGridView and export it to a .txt file that has the name of a column of DataGridView</p>
  
  <p>At the moment I have a button to export all data to a .txt gridview here is the code</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
      {   
          if (!Directory.Exists(@"D:\Carpeta"))
          {
              Directory.CreateDirectory(@"D:\Carpeta");
          }
  
          TextWriter sw = new StreamWriter(@"D:\Carpeta\Archivo.txt");
          int rowcount = TablaDatos.Rows.Count;
          for(int i = 0; i &lt; rowcount -1; i++)
          {
              sw.WriteLine(TablaDatos.Rows[i].Cells[0].Value.ToString()+"\t"
                           +TablaDatos.Rows[i].Cells[1].Value.ToString()+"\t"
                            +TablaDatos.Rows[i].Cells[2].Value.ToString()+"\t"
                             +TablaDatos.Rows[i].Cells[3].Value.ToString()+"\t");
          }
          sw.Close();
          MessageBox.Show("Datos Exportados correctamente");    
      }
  </code></pre>
  
  <p>I need to export row by row creating a txt for each row and not the entire DataGridView</p>
  
  <p><a href="https://i.stack.imgur.com/Jnjqc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jnjqc.jpg" alt="enter image description here"></a></p>