Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Button1_Click(object sender, EventArgs e)
- {
- update1();
- }
- private void update1()
- {
- string text = text = UpdatedArray();
- File.WriteAllText("account1.txt", text);
- }
- public string UpdatedArray()
- {
- filelist = new string[LineNo];
- row = GetRowNumber();
- int newbal; string strbal;
- newbal = Convert.ToInt32(label3.Text) + Convert.ToInt32(textBox1.Text);
- strbal = Convert.ToString(newbal);
- string username = login.accountname;
- TextReader sr = new StreamReader("account.txt");
- string line = "";
- bool found = false;
- string text = File.ReadAllText("account.txt");
- while ((line = sr.ReadLine()) != null)
- {
- string[] components = line.Split(" ".ToCharArray());
- if (components.Contains(username))
- {
- found = true;
- }
- if(found == true)
- {
- string str, str1, str2;
- str = components[5];
- str1 = line.Replace(str, strbal);
- str2 = string.Join(" ", str1);
- text = text.Replace(filelist[row], str2);
- }
- }
- sr.Close();
- return text;
- }
- public int GetRowNumber()
- {
- string username = login.accountname;
- TextReader sr = new StreamReader("account.txt");
- bool found = false;
- int i = 0;
- while (i < LineNo && !found)
- {
- filelist[i] = sr.ReadLine();
- if (filelist[i].Contains(username))
- found = true;
- else i++;
- }
- if (found == true)
- {
- row = i;
- sr.Close();
- }
- return row;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement