systems lab

profilerightnow
lab1_code_1.txt

foreach (DataRow dataRow in dataTable.Rows) { //Checks the "if" condition to see if the dataRow is on the last record. If true, the //".TrimEnd('\r')" method removes the blankline that is sent before the //StreamWriter closes by defualt. if (rowCount == (dataTable.Rows.Count - 1)) sw.Write(dataRow["item_id"].ToString() + dataRow["qoh"].ToString().PadLeft(4, '0').TrimEnd('\r')); else sw.WriteLine(dataRow["item_id"].ToString() + dataRow["qoh"].ToString().PadLeft(4, '0')); //Counter to accuraletly loop through the foreach. rowCount++; } //Closes the StreamWriter Stream sw.Close();