Ejemplo n.º 1
0
        /// <summary>
        /// To save as new file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                CurrentFilePath = SaveFileDialog.FileName;
                List <string> convertedLines = CSVSerialization.ToCSV(SerializedData);

                File.WriteAllLines(CurrentFilePath, convertedLines, Encoding.Default);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Append to existing file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void appendToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (AppendFileDialog.ShowDialog() == DialogResult.OK)
            {
                CurrentFilePath = AppendFileDialog.FileName;
                List <string> convertedLines = CSVSerialization.ToCSV(SerializedData);
                FileStream    fs             = new FileStream(CurrentFilePath, FileMode.Append);

                using (StreamWriter sw = new StreamWriter(fs, Encoding.Default))
                {
                    foreach (var item in convertedLines)
                    {
                        sw.WriteLine(item);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// To save current file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dfToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CurrentFilePath != null)
            {
                List <string> convertedLines = CSVSerialization.ToCSV(SerializedData);
                FileStream    fs             = new FileStream(CurrentFilePath, FileMode.Create);

                using (StreamWriter sw = new StreamWriter(fs, Encoding.Default))
                {
                    foreach (var item in convertedLines)
                    {
                        sw.WriteLine(item);
                    }
                }
            }
            else
            {
                MessageBox.Show("No current file availible, please use \"Save as\" option", "Error");
            }
        }