Safely migrate external tools configuration file from Local to Roaming folder.

This commit is contained in:
Riley McArdle
2011-05-12 17:45:35 -05:00
parent fae284ca86
commit 4f9e6ebbd4
2 changed files with 9 additions and 5 deletions

View File

@@ -784,7 +784,6 @@ Namespace App
End If
Else
If My.Settings.LoadConsFromCustomLocation = False Then
conL.ConnectionFileName = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile
Dim oldPath As String = GetFolderPath(SpecialFolder.LocalApplicationData) & "\" & My.Application.Info.ProductName & "\" & App.Info.Connections.DefaultConnectionsFile
Dim newPath As String = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile
If Not File.Exists(newPath) And File.Exists(oldPath) Then

View File

@@ -2,6 +2,7 @@ Imports System.IO
Imports WeifenLuo.WinFormsUI.Docking
Imports mRemoteNG.App.Runtime
Imports System.Xml
Imports System.Environment
Namespace Config
Namespace Settings
@@ -172,13 +173,17 @@ Namespace Config
End Sub
Public Sub LoadExternalAppsFromXML()
If File.Exists(App.Info.Settings.SettingsPath & "\" & App.Info.Settings.ExtAppsFilesName) = False Then
Dim oldPath As String = GetFolderPath(SpecialFolder.LocalApplicationData) & "\" & My.Application.Info.ProductName & "\" & App.Info.Settings.ExtAppsFilesName
Dim newPath As String = App.Info.Settings.SettingsPath & "\" & App.Info.Settings.ExtAppsFilesName
Dim xDom As New XmlDocument()
If File.Exists(newPath) Then
xDom.Load(newPath)
ElseIf File.Exists(oldPath) Then
xDom.Load(oldPath)
Else
Exit Sub
End If
Dim xDom As New XmlDocument()
xDom.Load(App.Info.Settings.SettingsPath & "\" & App.Info.Settings.ExtAppsFilesName)
For Each xEl As XmlElement In xDom.DocumentElement.ChildNodes
Dim extA As New Tools.ExternalApp
extA.DisplayName = xEl.Attributes("DisplayName").Value