This commit is contained in:
Jonathan Jenne 2023-10-04 13:58:26 +02:00
parent 278dda42a8
commit 2153e83426

View File

@ -1,4 +1,5 @@
Imports System.IO
Imports System.Windows.Forms
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging
@ -13,6 +14,28 @@ Public Class ConfigUtils
_File = New FilesystemEx(LogConfig)
End Sub
''' <summary>
''' Migrate a config file when the ProductName has changed
''' </summary>
''' <param name="pUserBasePath">The user config base path, should be Application.UserAppDataPath</param>
''' <param name="pProductName">The current or new product name</param>
''' <param name="pOldProductName">The old product name</param>
''' <returns></returns>
Public Function MigrateUserAppDataConfig(pUserBasePath As String, pProductName As String, pOldProductName As String)
Return MigrateAppDataConfig(pUserBasePath, ConfigManager(Of ConfigSample).USER_CONFIG_NAME, pProductName, pOldProductName)
End Function
''' <summary>
''' Migrate a config file when the ProductName has changed
''' </summary>
''' <param name="pCommonBasePath">The config base path, should be Application.CommonAppDataPath</param>
''' <param name="pProductName">The current or new product name</param>
''' <param name="pOldProductName">The old product name</param>
''' <returns></returns>
Public Function MigrateCommonAppDataConfig(pCommonBasePath As String, pProductName As String, pOldProductName As String)
Return MigrateAppDataConfig(pCommonBasePath, ConfigManager(Of ConfigSample).COMPUTER_CONFIG_NAME, pProductName, pOldProductName)
End Function
''' <summary>
''' Migrate a config file when the ProductName has changed
''' </summary>
@ -20,7 +43,7 @@ Public Class ConfigUtils
''' <param name="pProductName">The current or new product name</param>
''' <param name="pOldProductName">The old product name</param>
''' <returns></returns>
Public Function MigrateAppDataConfig(pBasePath As String, pConfigName As String, pProductName As String, pOldProductName As String)
Private Function MigrateAppDataConfig(pBasePath As String, pConfigName As String, pProductName As String, pOldProductName As String)
Dim oNewDirPath = pBasePath
Dim oOldDirPath = oNewDirPath.Replace(pProductName, pOldProductName)
Dim oNewFilePath = Path.Combine(oNewDirPath, pConfigName)