Nadekai
Nadekai
CC#
Created by Nadekai on 5/4/2024 in #help
I need to make this textbox not move
No description
32 replies
CC#
Created by Nadekai on 4/16/2024 in #help
✅ Lost again
After entering password and hitting enter, another login window opens, if I close all login windows, if the password was correct, it opens 2 main windows instead of 1.
190 replies
CC#
Created by Nadekai on 4/16/2024 in #help
I am lost
For some reason whenever I press enter, nothing happens, the MK_content doesn't get written into the file.
c#
using System;
using System.Collections.Generic;
using System.IO;


namespace Password_Manager
{

public partial class MainWindow : Window
{
public bool MK_exists = false;
public string MK_content = null;
public string MK_path = "Data\\MasterKey.txt";
public MainWindow()
{
InitializeComponent();

// Accessing variables




if (File.Exists(MK_path))
{
// Check if MasterKey.txt exists and has content
if (new FileInfo(MK_path).Length > 0)
{
MK_exists = true;
MK_content = File.ReadAllText(MK_path); // Read the content of MasterKey.txt
}
}
else
{
// Create MasterKey.txt if it doesn't exist
using (File.Create(MK_path)) { }
}

// Show the appropriate stack panel based on MK existence
if (MK_exists)
{
sp_MK_Login.Visibility = Visibility.Visible;
}
else
{
sp_MK_creation.Visibility = Visibility.Visible;
}

// Set the content of the password box if MK_content is not null or empty


debug_label.Content = MK_content;

tb_MK_PasswordBox_Creation.KeyDown += MK_PB_Creation_KeyDown;
}

private void MK_PB_Creation_KeyDown(object sender, KeyEventArgs e)
{
if(e.Key == Key.Enter)
{
if (!string.IsNullOrEmpty(MK_content))
{

tb_MK_PasswordBox_Creation.Password = MK_content;
File.WriteAllText(MK_path, MK_content);
}
}
}
}
}
c#
using System;
using System.Collections.Generic;
using System.IO;


namespace Password_Manager
{

public partial class MainWindow : Window
{
public bool MK_exists = false;
public string MK_content = null;
public string MK_path = "Data\\MasterKey.txt";
public MainWindow()
{
InitializeComponent();

// Accessing variables




if (File.Exists(MK_path))
{
// Check if MasterKey.txt exists and has content
if (new FileInfo(MK_path).Length > 0)
{
MK_exists = true;
MK_content = File.ReadAllText(MK_path); // Read the content of MasterKey.txt
}
}
else
{
// Create MasterKey.txt if it doesn't exist
using (File.Create(MK_path)) { }
}

// Show the appropriate stack panel based on MK existence
if (MK_exists)
{
sp_MK_Login.Visibility = Visibility.Visible;
}
else
{
sp_MK_creation.Visibility = Visibility.Visible;
}

// Set the content of the password box if MK_content is not null or empty


debug_label.Content = MK_content;

tb_MK_PasswordBox_Creation.KeyDown += MK_PB_Creation_KeyDown;
}

private void MK_PB_Creation_KeyDown(object sender, KeyEventArgs e)
{
if(e.Key == Key.Enter)
{
if (!string.IsNullOrEmpty(MK_content))
{

tb_MK_PasswordBox_Creation.Password = MK_content;
File.WriteAllText(MK_path, MK_content);
}
}
}
}
}
166 replies