[Feature] Resolve path from which the settings are upgraded in logfile (#147), version 1.0.17.13

This commit is contained in:
Markus Hofknecht 2021-04-16 18:59:35 +02:00
parent 2932ddf1b6
commit 85fd0371b5
3 changed files with 24 additions and 31 deletions

View file

@ -4,6 +4,7 @@
namespace SystemTrayMenu
{
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@ -25,16 +26,33 @@ namespace SystemTrayMenu
{
if (!Properties.Settings.Default.IsUpgraded)
{
// configs located at "%localappdata%\<AssemblyCompany>\"
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.IsUpgraded = true;
Properties.Settings.Default.Save();
FileVersionInfo versionInfo = FileVersionInfo.
GetVersionInfo(Assembly.GetEntryAssembly().Location);
Log.Info($"Settings upgraded from " +
$"%localappdata%\\{versionInfo.CompanyName}\\");
string upgradedFromPath = $"%localappdata%\\{versionInfo.CompanyName}\\";
try
{
upgradedFromPath = System.IO.Path.GetFullPath(upgradedFromPath);
}
catch (Exception ex)
{
if (ex is ArgumentException ||
ex is System.Security.SecurityException ||
ex is NotSupportedException ||
ex is PathTooLongException)
{
Log.Warn($"Resolve path {upgradedFromPath} failed", ex);
}
else
{
throw;
}
}
Log.Info($"Settings upgraded from {upgradedFromPath}");
}
}

View file

@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.17.12")]
[assembly: AssemblyFileVersion("1.0.17.12")]
[assembly: AssemblyVersion("1.0.17.13")]
[assembly: AssemblyFileVersion("1.0.17.13")]

View file

@ -188,31 +188,6 @@ namespace SystemTrayMenu.UserInterface
{
}
///// <summary>
///// Check if OneDrive is blocking hotkeys
///// </summary>
///// <returns>true if onedrive has hotkeys turned on</returns>
// private static bool IsOneDriveBlockingHotkey()
// {
// if (!Environment.OSVersion.IsWindows10())
// {
// return false;
// }
// var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
// var oneDriveSettingsPath = Path.Combine(localAppData, @"Microsoft\OneDrive\settings\Personal");
// if (!Directory.Exists(oneDriveSettingsPath))
// {
// return false;
// }
// var oneDriveSettingsFile = Directory.GetFiles(oneDriveSettingsPath, "*_screenshot.dat").FirstOrDefault();
// if (!File.Exists(oneDriveSettingsFile))
// {
// return false;
// }
// var screenshotSetting = File.ReadAllLines(oneDriveSettingsFile).Skip(1).Take(1).First();
// return "2".Equals(screenshotSetting);
// }
/// <summary>
/// Displays a dialog for the user to choose how to handle hotkey registration failures:
/// retry (allowing to shut down the conflicting application before),