New default config values

This commit is contained in:
2023-03-31 11:01:31 +02:00
parent 7ab3a64d56
commit 4652442794

View File

@@ -24,45 +24,45 @@ namespace Password_Manager
while (!success)
{
if (File.Exists(CONFIGPATH))
{
StreamReader sr = new StreamReader(CONFIGPATH);
string? path = null, recipient = null;
while (!sr.EndOfStream)
if (File.Exists(CONFIGPATH))
{
string[]? fields = sr.ReadLine().Split(DELIMETER);
if (fields != null)
StreamReader sr = new StreamReader(CONFIGPATH);
string? path = null, recipient = null;
while (!sr.EndOfStream)
{
if (fields[0] == PATH)
string[]? fields = sr.ReadLine().Split(DELIMETER);
if (fields != null)
{
path = fields[1];
if (fields[0] == PATH)
{
path = fields[1];
}
else if (fields[0] == RECIPIENT)
{
recipient = fields[1];
}
}
else //probably an empty line or something
{
continue;
}
else if (fields[0] == RECIPIENT)
{
recipient = fields[1];
}
}
else //probably an empty line or something
if (path != null && recipient != null)
{
continue;
Configuration = new Config(path, recipient);
success = true;
}
else
{
throw new InvalidConfigurationException("One or more required fileds were missing from the configuration file.");
}
}
if (path != null && recipient != null)
{
Configuration = new Config(path, recipient);
success = true;
}
else
{
throw new InvalidConfigurationException("One or more required fileds were missing from the configuration file.");
}
else
{
CreateDefaultConfig();
}
}
else
{
CreateDefaultConfig();
}
}
}
public static string GetPath()
@@ -79,9 +79,10 @@ namespace Password_Manager
{
try
{
string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
StreamWriter sw = new StreamWriter(CONFIGPATH);
sw.WriteLine(RECIPIENT + DELIMETER + "typo");
sw.WriteLine(PATH + DELIMETER + @"C:\Users\Typo\pass");
sw.WriteLine(RECIPIENT + DELIMETER + user);
sw.WriteLine(PATH + DELIMETER + SpecialDirectories.CurrentUserApplicationData);
sw.Close();
}
catch (Exception e)