///This section includes the code for implementing the data set and its tables. /// //Creates a DataTable from input method CreateDataTableFromFile //Converts From DataTable object to String Array for a 2D array of any size. //Outputs public void GetTableData(out DataTable dt, out string[,] results) { DataSet_Processing instance = new DataSet_Processing(); /////GOT HUNGUP HERE BADLY! READ MORE. dt = instance.CreateDataTableFromFile("somename", _tableFileLocation); //TODO come back and use name field results = new string[dt.Rows.Count, dt.Columns.Count]; for (int index = 0; index < dt.Rows.Count; index++) { for (int columnIndex = 0; columnIndex < dt.Columns.Count; columnIndex++) { results[index, columnIndex] = dt.Rows[index][columnIndex].ToString(); } } }
public void ReadTextFile() { string line; try { this.InputText.Clear(); //Pass the file path and file name to the StreamReader constructor StreamReader sr = new StreamReader("C:\\temp\\Jamaica.txt"); //Read the first line of text line = sr.ReadLine(); //Continue to read until you reach end of file while (line != null) { //write the lie to console window //this.InputText.SelectionStart = InputText.Text.Length; this.InputText.AppendText(line); this.InputText.AppendText(Environment.NewLine); //Read the next line line = sr.ReadLine(); } //close the file sr.Close(); String dt; DataSet_Processing instance = new DataSet_Processing(); instance.CreateDataTableFromFile(testFileLocation, testFileLocation); ///create the table, this is expecting a table name, too } catch (Exception e) { MessageBox.Show("Exception: " + e.Message); } finally { MessageBox.Show("Executing finally block."); } }