I have to make a program that reads a TXT file in the folder where my program is and has to update it through textbox1.text and textbox2.text.
**My question is:**
I have 2 text boxes, which are filled out with entries etc. by the user.
These data or entries of 2 text boxes (textbox1.text & textbox2.text) should be saved in the same folder in the LOGS.TXT file. All entries entered subsequently in text boxes must also be saved as a new line, so what has been entered in these two text boxes so far must not be lost
At the end it has to be checked whether these entries have already existed, because if so, the program has to say that it doesn't work because either Textbox1.Text has already saved something in LOGS.TXT and/or Textbox2.Text (preferably with IF and else function)
Can you help me please. I'm relatively new to C# and I can't find anything on YouTube etc. at all! :/
What I have tried:
string strTheFile = File.ReadAllText(@"LOGS.TXT");
if (strTheFile.Contains(trackingcodetxt.Text + rechnungsnummertxt.Text + Environment.NewLine))
{
MessageBox.Show("ERROR! Enteries allready exist", "Auto-Check | V1.0.0", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else {
int stringLength = (int)laengeupdown.Value;
trackingcodetxt.Text = "B2B" + GetRandomString(stringLength);
string folderPath = Path.Combine(this.pfadtxt.Text, this.trackingcodetxt.Text + ".txt");
using (StreamWriter sw = new StreamWriter(folderPath))
{
sw.WriteLine(";" + this.trackingcodetxt.Text + ";;;;;;;;;;;;;;;;;;;;;" + this.rechnungsnummertxt.Text + ";" + this.datenbankcombobox.Text);
MessageBox.Show("Erfolgreich", "Auto-Save | V1.0.2", MessageBoxButtons.OK, MessageBoxIcon.Information);
clearbtn.Enabled = true;
infolabel.Text = "Erfolgreich: " + rechnungsnummertxt.Text;
infolabel.ForeColor = Color.DarkGreen;