public Form_Main() { InitializeComponent(); Main = this; Usercontol_Sidepanel_Chooseuser.uschu = new Usercontol_Sidepanel_Chooseuser(); Usercontrol_Background_Description.ubd = new Usercontrol_Background_Description(); Usercontrol_Sidepanel_Createuser.uscu = new Usercontrol_Sidepanel_Createuser(); Usercontrol_Sidepanel_Password.usp = new Usercontrol_Sidepanel_Password(); Usercontrol_Sidepanel_Main.usm = new Usercontrol_Sidepanel_Main(); DoubleBuffered = true; }
private void Button_CreateUser_Click(object sender, EventArgs e) { Usercontol_Sidepanel_Chooseuser uscho = new Usercontol_Sidepanel_Chooseuser(); Form_Main fm = new Form_Main(); if (!string.IsNullOrWhiteSpace(Textbox_Name.Text)) { CasedLetter = Textbox_Name.Text.Substring(0, 1).ToUpper(); RestName = Textbox_Name.Text.Substring(1, Textbox_Name.Text.Length - 1).ToLower(); } CasedName = CasedLetter + RestName; CreateUser(CasedName, Textbox_Password.Text); }
public void CreateUser(string name, string password) { Usercontol_Sidepanel_Chooseuser uschu = new Usercontol_Sidepanel_Chooseuser(); Form_Main fm = new Form_Main(); if (string.IsNullOrWhiteSpace(Textbox_Name.Text) || string.IsNullOrWhiteSpace(Textbox_Password.Text)) { Label_Error.Text = "Reenter username/password"; return; } else if (Form_Main.Users.Count == 3) { Label_Error.Text = "Maximum user count reached"; return; } else if (Directory.Exists("@" + name.ToLower())) { Label_Error.Text = "User already exists"; return; } else if (!Directory.Exists("@" + name.ToLower()) && Form_Main.Users.Count != 3) { Directory.CreateDirectory("@" + name.ToLower()); string BaseDirectory = "@" + name.ToLower(); string FileDirectory = "#" + name.ToLower(); StreamWriter sp = new StreamWriter(Path.Combine(BaseDirectory, FileDirectory) + "p"); sp.Write(password); sp.Flush(); sp.Close(); StreamWriter sn = new StreamWriter(Path.Combine(BaseDirectory, FileDirectory) + "n"); sn.Write(name); sn.Flush(); sn.Close(); File.Encrypt(Path.Combine(BaseDirectory, FileDirectory) + "p"); File.Encrypt(Path.Combine(BaseDirectory, FileDirectory) + "n"); Form_Main.Main.LogIn(name, password); } }