here is the problem: I've got two classes. Form 1 creates a .txt-File and sets two values (Strings) in it. Now I want to get these two strings by pressing a button(bDirekt), and set each string in a Textbox in Form 2.
Form 1 (should be correct as far as I know, but please tell me if I'm wrong):
public void Txfw()
{
string txBetrag = gBetrag.Text;
string txMonate = gMonate.Text;
string[] vars = new string[] { txBetrag, txMonate };
using (StreamWriter sw = new StreamWriter(@"C:\Users\p2\Desktop\variablen.txt"))
{
foreach (string s in vars)
{
sw.WriteLine(s);
}
}
}
Form 2 (got no idea how to go ahead):
private void bDirekt_Click(object sender, RoutedEventArgs e)
{
using (StreamReader sr = new StreamReader("variables.txt")) ;
string line = "";
while ((line = sr.ReadLine()) != null)
{
monate2.Text =
}
}
I really appreciate your help.