One of my applications has several small xml files saved in the ProgramData folder that contain configuration information. This works nicely, but when a new version of the application is installed, I need to bring these files forward so the user doesn’t lose their settings. It seems like there must be a better way to do this, but the following looks through previous folder versions for the files.
The folder path follows the format C:\ProgramData\Company Name\Program Name\188.8.131.52
Dim ds As New DataSet Dim a As String = My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData Dim b As String = "\Job.xml" If IO.File.Exists(a & b) Then ds.ReadXml(a & b) Else Dim di As DirectoryInfo = Directory.GetParent(a) Dim dirs = di.GetDirectories.OrderByDescending(Function(f) f.FullName) For Each d As DirectoryInfo In dirs If d.FullName <> a Then If File.Exists(d.FullName & b) Then ds.ReadXml(d.FullName & b) Exit For End If End If Next End If