Config: improve config migration
This commit is contained in:
parent
aa27dd8c1c
commit
441f65915f
@ -23,8 +23,15 @@ Public Class ConfigUtils
|
|||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function MigrateAppDataConfig(pUserAppDataPath As String, pProductName As String, pOldProductName As String)
|
''' <summary>
|
||||||
Dim oNewDirPath = pUserAppDataPath
|
''' Migrate a config file when the ProductName has changed
|
||||||
|
''' </summary>
|
||||||
|
''' <param name="pBasePath">The config base path, can be Application.UserAppDataPath or 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 MigrateAppDataConfig(pBasePath As String, pProductName As String, pOldProductName As String)
|
||||||
|
Dim oNewDirPath = pBasePath
|
||||||
Dim oOldDirPath = oNewDirPath.Replace(pProductName, pOldProductName)
|
Dim oOldDirPath = oNewDirPath.Replace(pProductName, pOldProductName)
|
||||||
Dim oNewFilePath = Path.Combine(oNewDirPath, USER_CONFIG)
|
Dim oNewFilePath = Path.Combine(oNewDirPath, USER_CONFIG)
|
||||||
Dim oOldFilePath = Path.Combine(oOldDirPath, USER_CONFIG)
|
Dim oOldFilePath = Path.Combine(oOldDirPath, USER_CONFIG)
|
||||||
@ -45,7 +52,7 @@ Public Class ConfigUtils
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
_Logger.Info("Migrating Config from [{0}] to [{1}]", pOldProductName, pProductName)
|
_Logger.Info("Migrating Config from [{0}] to [{1}]", pOldProductName, pProductName)
|
||||||
File.Copy(oOldFilePath, oNewFilePath)
|
File.Move(oOldFilePath, oNewFilePath)
|
||||||
Return True
|
Return True
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user