private void BtnConvert_Click(object sender, EventArgs e) { lblFeedback.Text = "Working..."; input = tbInput.Text; output = mimicInputName ? "" : tbOutput.Text; if (input == "") { lblFeedback.Text = "Input file field is empty."; tbInput.BackColor = Color.IndianRed; } else { initializeVariables(); if (output == "") { filepath = Path.GetDirectoryName(input) + "\\" + Path.GetFileNameWithoutExtension(input) + ".kml"; output = tbOutput.Text = filepath; //considering changing Clear button to a checkbox, to process multiple files in a row with auto-generated names } try { beginDocument(); fieldCount = csv.FieldCount; headers = csv.GetFieldHeaders(); for (int i = 0; i < fieldCount; i++) { headers[i] = headers[i].ToLower(); headers[i] = XmlConvert.EncodeName(headers[i]); headers[i] = headers[i].Replace(":", "-"); } while (csv.ReadNextRecord()) //considering adding a boolean xmlOpen or xmlInError { processRecord(); } finishDocument(); } catch (IOException IOex) { DialogResult result = MessageBox.Show(errMsgFileUnavailable + IOex.ToString(), errCapFileAcc, MessageBoxButtons.OK); pBar.Value = 0; } catch (UnauthorizedAccessException unauthEx) { DialogResult result = MessageBox.Show(errMsgFilePriv + unauthEx.ToString(), errCapFileAcc, MessageBoxButtons.OK); pBar.Value = 0; } } }
private void logFileToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { try { file_directories = openFileDialog1.FileNames; sorted_logs = s.sort_log_into_list(file_directories); updateStatusStrip(); } catch (IOException IOex) { MessageBox.Show("Error beim lesen der Datei! " + IOex.ToString()); } } }
/// <summary> /// Toolstrip menu item that says 'File'. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void directoryToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { try { file_directories = Directory.GetFiles(folderBrowserDialog1.SelectedPath); sorted_logs = s.sort_log_into_list(file_directories); updateStatusStrip(); } catch (IOException IOex) { MessageBox.Show("Error beim lesen der Datei! " + IOex.ToString()); } } }