Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool fl = false;
- sr = new StreamReader("produkt.txt");
- while (!sr.EndOfStream)
- {
- string line = sr.ReadLine();
- linePro = line.Split(';');
- // MessageBox.Show("vtri 1: " + linePro[3]);
- string name=linePro[1];
- // MessageBox.Show("name: " + linePro[1]);
- int n=listBox2.Items.Count;
- for (int i = 0; i < n;i++ )
- {
- // MessageBox.Show("hej");
- if (listBox2.Items[i].ToString().Equals(name))
- {
- // MessageBox.Show("hej inne");
- int antal = Int32.Parse(linePro[3]);
- updateAntal = antal - 1;
- MessageBox.Show("vtri 1: " + updateAntal);
- fl = true;
- }
- }
- }
- sr.Close();
- if(fl==true)
- {
- sw = new StreamWriter("produkt.txt", true);
- int n2 = listBox1.Items.Count;
- for (int i = 0; i < n2; i++)
- {
- sw.WriteLine(linePro[0] + ";" + linePro[1] + ";" + linePro[2] + ";" + updateAntal);
- }
- sw.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement