I have the following piece of code which opens a text file and reads all the lines in the file and storing it into a string array.
Which then checks if
Try try catch:
string x;
string log = @"C:\Users\Log.txt";
string ruta = @"C:\Users\x.txt";
if (File.Exists(ruta))
{
try
{
x = File.ReadAllText(ruta);
}
catch (Exception ex)
{
File.AppendAllText(ruta, "Something");
File.AppendAllText(log, Environment.NewLine + DateTime.Now.ToString() + ": The file not contain a string. " + ex.Message);
}
}