Änderung
- Methoden zum Abfragen ob die Schlüssel existieren dazu - Methode zum Abfragen ob der Wert null oder leer ist dazu
This commit is contained in:
parent
0159f5f425
commit
64871eb870
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -264,6 +264,65 @@ namespace Eugen.ESystem
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the roaming path exists
|
||||
/// </summary>
|
||||
/// <returns>'True' if the roaming path exists, otherwise 'false'</returns>
|
||||
public bool RoamingPathExists()
|
||||
{
|
||||
return Directory.Exists(RoamingPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the main key exists
|
||||
/// </summary>
|
||||
/// <returns>'True' if the main key exists, otherwise 'false'</returns>
|
||||
public bool MainKeyExists()
|
||||
{
|
||||
return Directory.Exists(RoamingPath + "\\" + MainKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the sub key exists
|
||||
/// </summary>
|
||||
/// <returns>'True' if the sub key exists, otherwise 'false'</returns>
|
||||
public bool SubKeyExists()
|
||||
{
|
||||
return Directory.Exists(RoamingPath + "\\" + MainKey + "\\" + SubKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the key exists
|
||||
/// </summary>
|
||||
/// <returns>'True' if the key exists, otherwise 'false'</returns>
|
||||
public bool KeyExists()
|
||||
{
|
||||
return Directory.Exists(RoamingPath + "\\" + MainKey + "\\" + SubKey + "\\" + Key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the key is 'null' or 'empty'
|
||||
/// </summary>
|
||||
/// <returns>'True' if the key is 'null' or 'empty', otherwise 'false'</returns>
|
||||
public bool ValueIsNullOrEmpty()
|
||||
{
|
||||
if (KeyExists())
|
||||
{
|
||||
if (String.IsNullOrEmpty(ReadKey()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetAppData()
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("APPDATA"); //Ermittelt den Pafad des Verzeichnisses '%APPDATA%\Roaming'
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -151,6 +151,7 @@ namespace Test_Roaming
|
||||
roaming.DeleteMainKey(); //Hauptschlüssel löschen
|
||||
|
||||
labelResult.Text = "MainKey: " + mainKey + "\nSubKey: " + subKey + "\nKey: " + key + "\nValue: " + value + "\n\nSchreibe Key nach \'AppData\\Roaming\\'\nGelesener Wert: " + redvalue + "\nLösche Key/SubKey/MainKey";
|
||||
labelResult.Text += "\n\nMainKey exist: " + roaming.MainKeyExists() + "\nSubKey exist: " + roaming.SubKeyExists() + "\nKey exist: " + roaming.KeyExists() + "\nValue ist null oder leer: " + roaming.ValueIsNullOrEmpty();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user