Delete last line in txt file
- by user3658127
I wrote a foreach loop for my datagridview to write all rows to txt file.
I have a problem as it adds 2 empty lines at the end, as 1 row is full of empty cells after adding/reading to datagrid view.
Is there any way to omit the last line or delete it in txt?
foreach (DataGridViewRow item in this.DB.Rows)
{
foreach (DataGridViewCell item2 in item.Cells)
{
if(item2.Value != null)
filewrite.Write(item2.Value.ToString() + " ");
}
filewrite.WriteLine("");
}