I am reading the contents of a text file into variables. All works well if the text file does not exist, or it does exist and contains 4 rows of data. But I need to account for rows being empty or null. How can I check this?
Code:
string filename = @"C:\Program Files\Picture Capture\Settings.txt";
if (File.Exists(filename))
{
StreamReader reader = new StreamReader(filename);
string strAllFile = reader.ReadToEnd().Replace("\r\n", "\n").Replace("\n\r", "\n");
string[] arrLines = strAllFile.Split(new char[] { '\n' });
//need to account for an empty file
this.clienttype = arrLines[0];
this.servername = arrLines[1];
this.username = arrLines[2];
this.password = arrLines[3];
reader.Close();
Comment