public void parseStormsToDatabase( ref TropicalCycloneDatabase database, string[] fileText, ref string errorMessages) { int numberOfLines = fileText.Length; int linePosition = 0; while (linePosition < numberOfLines) { TropicalCyclone temp = new TropicalCyclone(); /// Grab header line for storm. /// Basin_Number_Year, Name, number of records string[] line = fileText[linePosition].Split(','); // Check basin string basinTemp = line[0] + line[1]; } }
// Variables. static void Main(string[] args) { /// <summary> /// variable that will be a string composition of entire file /// </summary> string[] fileText = null; /// <summary> /// String for file path. /// </summary> string filePath = @"C:\Users\thomashinson\Documents\TCdata\"; /// <summary> /// filename /// </summary> string fileName = string.Empty; /// <summary> /// Read the filename from console. /// </summary> Console.Write("Please input storm list file name (.txt): "); fileName = Console.ReadLine(); /// <summary> /// Attempt to open file, if not, add error messages. /// </summary> string errorMessages = string.Empty; /// Try block to read file. try { if (File.Exists(filePath + fileName)) { fileText = System.IO.File.ReadAllLines(@"C:\Users\thomashinson\Documents\TCdata\" + fileName); } else { errorMessages += (Environment.NewLine + "File does not exist as specified." + Environment.NewLine); } } catch (Exception ex) { errorMessages += (Environment.NewLine + ex.Message + Environment.NewLine); } /// <summary> /// Create a TC_Database object. /// </summary> TropicalCycloneDatabase database = new TropicalCycloneDatabase(); /// <summary> /// Pass fileText to file handler to create individual files. /// </summary> /// <summary> /// Determine if errorMessages is empty and if successful /// </summary> if (errorMessages == "") { Console.WriteLine("Program execution was successful."); } else { Console.WriteLine(errorMessages); } Console.ReadKey(); }