From 441f65915fc7ec762ae6ee3adf5fa47083c7d0b1 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 4 Oct 2023 13:21:03 +0200 Subject: [PATCH] Config: improve config migration --- Config/ConfigUtils.vb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Config/ConfigUtils.vb b/Config/ConfigUtils.vb index e9fce55a..7bf25391 100644 --- a/Config/ConfigUtils.vb +++ b/Config/ConfigUtils.vb @@ -23,8 +23,15 @@ Public Class ConfigUtils End If End Function - Public Function MigrateAppDataConfig(pUserAppDataPath As String, pProductName As String, pOldProductName As String) - Dim oNewDirPath = pUserAppDataPath + ''' + ''' Migrate a config file when the ProductName has changed + ''' + ''' The config base path, can be Application.UserAppDataPath or Application.CommonAppDataPath + ''' The current or new product name + ''' The old product name + ''' + Public Function MigrateAppDataConfig(pBasePath As String, pProductName As String, pOldProductName As String) + Dim oNewDirPath = pBasePath Dim oOldDirPath = oNewDirPath.Replace(pProductName, pOldProductName) Dim oNewFilePath = Path.Combine(oNewDirPath, USER_CONFIG) Dim oOldFilePath = Path.Combine(oOldDirPath, USER_CONFIG) @@ -45,7 +52,7 @@ Public Class ConfigUtils End If _Logger.Info("Migrating Config from [{0}] to [{1}]", pOldProductName, pProductName) - File.Copy(oOldFilePath, oNewFilePath) + File.Move(oOldFilePath, oNewFilePath) Return True Catch ex As Exception