Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. class UserRemove : Users
  2. {
  3. //public int ID_User { get; private set; }
  4. //public string name { get; private set; }
  5.  
  6. public int _ID_Usun { get; private set; }
  7. public string _name_usun { get; private set; }
  8.  
  9. string[] lines_matrix;
  10. string lines;
  11.  
  12. public void RemoveUser(int _ID_Usun)
  13. {
  14. ID_User = _ID_Usun;
  15. name = _name_usun;
  16.  
  17. Console.WriteLine("\n Usuń użytkownika z bazy. \n Podaj ID:");
  18. this._ID_Usun = Convert.ToInt32(Console.ReadLine());
  19. //Convert.ToString(this._ID_Usun);
  20.  
  21. //Console.WriteLine(" Podaj imię i nazwisko");
  22. //this._name_usun = Console.ReadLine();
  23.  
  24. //using (StreamReader sr_users = new StreamReader("Users.txt"))
  25.  
  26.  
  27. //if (String.Equals(Convert.ToString(this._ID_Usun), sr_users.ReadToEnd().Contains(Convert.ToString(this._ID_Usun))))
  28.  
  29. lines_matrix = File.ReadAllLines("Users.txt");
  30. //
  31. //using (FileStream fs = File.OpenRead("Users.txt"))
  32. using (System.IO.StreamWriter file = new System.IO.StreamWriter("Users.txt"))
  33. {
  34. //BinaryReader bin_reader = new BinaryReader(fs);
  35.  
  36.  
  37. Dictionary<int, string> UsersList = GetUsersList();
  38. string s_ID_Usun = Convert.ToString(this._ID_Usun);
  39. lines = lines.Replace(s_ID_Usun, "0");
  40.  
  41. file.WriteLine(lines);
  42. UsersList.Remove(this._ID_Usun);
  43. //lines_matrix = File.ReadAllLines("Users.txt");
  44.  
  45. //foreach (var entry in UsersList)
  46. //file.WriteLine("[{0} {1}]", entry.Key, entry.Value);
  47. //using (System.IO.StreamWriter file = new System.IO.StreamWriter("Users.txt"))
  48. Console.WriteLine("Użytkownik" + "\t" + Convert.ToString(this._ID_Usun) + "\t został usunięty z bazy.");
  49. }
  50.  
  51.  
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement