PKHeX/PKHeX.WinForms/Util/CyberGadgetUtil.cs
Kurt c8563a3737 Respacening
Style guidelines, handle a bunch of files
no functional change
2018-07-26 19:34:27 -07:00

39 lines
1.4 KiB
C#

using System;
using System.IO;
namespace PKHeX.WinForms
{
public static class CyberGadgetUtil
{
public static string GetTempFolder() => Path.Combine(Path.GetTempPath(), "3DSSE");
public static string GetCacheFolder() => Path.Combine(GetBackupLocation(), "cache");
private static string GetRegistryBase() => @"SOFTWARE\CYBER Gadget\3DSSaveEditor";
private static string GetRegistryValue(string key)
{
Microsoft.Win32.RegistryKey currentUser = Microsoft.Win32.Registry.CurrentUser;
Microsoft.Win32.RegistryKey key3 = currentUser.OpenSubKey(GetRegistryBase());
if (key3 == null)
return null;
string str = key3.GetValue(key) as string;
key3.Close();
currentUser.Close();
return str;
}
private static string GetBackupLocation()
{
string registryValue = GetRegistryValue("Location");
if (!string.IsNullOrEmpty(registryValue))
{
Directory.CreateDirectory(registryValue);
return registryValue;
}
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "3DSSaveBank");
if (Directory.Exists(GetRegistryBase()))
Directory.CreateDirectory(path);
return path;
}
}
}