Hi all, I was looking for ideas on improving the following code
static void Main(string[] args)
{
bool validInput1 = false;
string input1 = string.Empty;
bool validInput2 = false;
string input2 = string.Empty;
bool validFilePath = false;
string filePath = string.Empty;
try
{
Console.WriteLine("Import process started.");
while (!validFilePath)
{
Console.Write("Please enter the full path to the file you would like to import: ");
filePath = Console.ReadLine().Replace("\"","");
if (File.Exists(filePath))
validFilePath = true;
}
while (!validInput1)
{
Console.Write("Enter a valid eventID the import file: ");
input1 = Console.ReadLine();
if (ValidEventID(input1.Trim().Length))
validInput1 = true;
}
while (!validInput2)
{
Console.Write("Enter a valid import type code: ");
input2 = Console.ReadLine();
if (input2.Trim().ToUpper() == "EX" || input2.Trim().ToUpper() == "EL")
validInput2 = true;
}
var records = Utilities.ParseCSV(filePath);
var import = new Import
{
EventId = input1,
ImportType = input2
};
import.ImportEventDates(records);
Console.WriteLine("Import process completed.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Error encountered");
Console.WriteLine(ex.ToString());
Console.ReadLine();
}
}
Thanks in advance for any help