First things first,I am very new to C# and programming all around. I have a standalone program that will read XML files in a certain location and convert them to plaintext files.
And I have a windows forms app that has a file directory and will display the chosen file in a textbox.
{
Stream myStream;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if ((myStream = openFileDialog1.OpenFile())!= null)
{
string strfilename = openFileDialog1.FileName;
string filetext = File.ReadAllText(strfilename);
textBox1.Text = filetext;
}
}
}
Below is a snippet of my conversion program.
string[] files = Directory.GetFiles("C:\\articles");
foreach (string file in files)
{
List<string> translatedLines = new List<string>();
string[] lines = File.ReadAllLines(file);
foreach(string line in lines)
{
if (line.Contains("\"check\""))
{
string pattern = "<[^>]+>";
string replacement = " ";
Regex rgx = new Regex(pattern);
string result = rgx.Replace(line, replacement);
translatedLines.Add(result);
}
}
How would I modify my program to take the input from the textbox and then perform its conversion? (And Yes I'm aware I have to combine the two programs.)