Note that there are some explanatory texts on larger screens.

plurals
  1. POBest method for comparing XML folder data
    primarykey
    data
    text
    <p>We are migrating server environments from one network to another. The networks are completely separated and cannot see each other. I am writing a program that will compare the files on our current production file server with the files on our future production file server. </p> <p>The program needs to list the following:</p> <ul> <li>Files missing in future server from current production server</li> <li>Files that are out of date in the future server from our production server</li> </ul> <p>The quickest way I could think of was to create a program that would browse through each folder and create an object to hold all files and folders. I then took that structure and serialize it into XML format. The end result is that I would have two files containing all files and folders on each server.</p> <p>My problem now is that I need an easy way to compare the two files to see any discrepancies. The method that I thought of would be to deserialize the current production XML file back to the objects, and loop through each file/folder checking to see if the files exist on the future production server.</p> <p>Besides manually looping through each file, is there an easier way to compare the two XML files to see which objects are different?</p> <p>Here is the code I am using to generate the two files:</p> <pre><code>Imports System.IO Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim objFolder As New Folder objFolder = GetFolder("FOLDER TO BROWSE") Dim strObjects As String = SerializeObject(objFolder) With New StreamWriter("Out Path") .Write(strObjects) End With End Sub Function GetFolder(ByVal strPath As String) As Folder Dim objFolder As New Folder For Each File In New DirectoryInfo(strPath).GetFiles Dim oFile As New File oFile.Name = File.Name oFile.FullName = File.FullName oFile.DateCreated = File.CreationTime oFile.DateModified = File.LastWriteTime objFolder.lstFiles.Add(oFile) Next For Each Folder In New DirectoryInfo(strPath).GetDirectories objFolder.lstFolders.Add(GetFolder(Folder.FullName)) Next Return objFolder End Function Public Shared Function SerializeObject(ByVal objToSerialize As Object) As String Dim objXML As New Xml.Serialization.XmlSerializer(objToSerialize.GetType) Dim sw As New IO.StringWriter() objXML.Serialize(sw, objToSerialize) Return sw.ToString() End Function Public Shared Function DeserializeObject(ByVal strSerializedObject As String, ByVal objType As Type) As Object Dim objXML As New Xml.Serialization.XmlSerializer(objType) Dim sr As New IO.StringReader(strSerializedObject) Return CType(objXML.Deserialize(sr), Object) End Function End Class &lt;Serializable(), Xml.Serialization.XmlInclude(GetType(File))&gt; _ Public Class Folder Public lstFiles As New List(Of File) Public lstFolders As New List(Of Folder) End Class &lt;Serializable()&gt; _ Public Class File Public Name As String Public FullName As String Public DateCreated As String Public DateModified As String End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload