mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
PersonalPath.cfg path moved from %localappdata%\ShareX to Documents\ShareX and gonna be automatically migrated
This commit is contained in:
parent
59397b8b98
commit
1c325dfb9c
1 changed files with 26 additions and 1 deletions
|
@ -116,10 +116,15 @@ private static string PersonalPathConfigFilePath
|
|||
return oldPath;
|
||||
}
|
||||
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppName, PersonalPathConfigFileName);
|
||||
return CurrentPersonalPathConfigFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly string CurrentPersonalPathConfigFilePath = Path.Combine(DefaultPersonalFolder, PersonalPathConfigFileName);
|
||||
|
||||
private static readonly string PreviousPersonalPathConfigFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
AppName, PersonalPathConfigFileName);
|
||||
|
||||
private static readonly string PortableCheckFilePath = Helpers.GetAbsolutePath("Portable");
|
||||
private static readonly string PortableAppsCheckFilePath = Helpers.GetAbsolutePath("PortableApps");
|
||||
public static readonly string NativeMessagingHostFilePath = Helpers.GetAbsolutePath("ShareX_NativeMessagingHost.exe");
|
||||
|
@ -379,6 +384,8 @@ private static void UpdatePersonalPath()
|
|||
|
||||
private static void CheckPersonalPathConfig()
|
||||
{
|
||||
MigratePersonalPathConfig();
|
||||
|
||||
string customPersonalPath = ReadPersonalPathConfig();
|
||||
|
||||
if (!string.IsNullOrEmpty(customPersonalPath))
|
||||
|
@ -396,6 +403,24 @@ private static void CheckPersonalPathConfig()
|
|||
}
|
||||
}
|
||||
|
||||
private static void MigratePersonalPathConfig()
|
||||
{
|
||||
if (File.Exists(PreviousPersonalPathConfigFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
Helpers.CreateDirectoryFromFilePath(CurrentPersonalPathConfigFilePath);
|
||||
File.Move(PreviousPersonalPathConfigFilePath, CurrentPersonalPathConfigFilePath);
|
||||
File.Delete(PreviousPersonalPathConfigFilePath);
|
||||
Directory.Delete(Path.GetDirectoryName(PreviousPersonalPathConfigFilePath));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.ShowError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadPersonalPathConfig()
|
||||
{
|
||||
if (File.Exists(PersonalPathConfigFilePath))
|
||||
|
|
Loading…
Reference in a new issue