Patchlister Hilfe vb.net

11/06/2015 11:06 Du.ke#1
Hallo Liebe Com,

Ich habe folgendes Problem.

Da bei dem Patcher Source von Hanashi´s Patcher V2 ein Patchlister für den WebSpace dabei ist und er mir immer eine Leere List datei auswirft wollte ich mittels VB.Net einen Lister erstellen.

Das Problem dabei ist das der Lister von mir nicht genauso listet wie der von Hanashi bitte Helft mir Thanks.

Code zum erstellen der xml Liste:


Code:
 Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        If BackgroundWorker1.CancellationPending = True Then
            BackgroundWorker1.CancelAsync()
        End If
        Dim Files As List(Of String) = GetFiles(My.Computer.FileSystem.CurrentDirectory & "\", True)

        Dim XmlDoc As New XmlDocument

        'Write down the XML declaration
        Dim XmlDeclaration As XmlDeclaration = XmlDoc.CreateXmlDeclaration("1.0", "UTF-8", Nothing)

        'Create the root element
        Dim RootNode As XmlElement = XmlDoc.CreateElement("PatchList")
        XmlDoc.InsertBefore(XmlDeclaration, XmlDoc.DocumentElement)
        XmlDoc.AppendChild(RootNode)

        'Create a new <Category> element and add it to the root node
        Dim ParentNode As XmlElement = XmlDoc.CreateElement("PatchFiles")

        'Set attribute name and value!


        XmlDoc.DocumentElement.PrependChild(ParentNode)

        'Create the required nodes


        For Each File In Files
            If File.Contains(Process.GetCurrentProcess.MainModule.FileName) Then

            Else

                Dim Checksum As String = MD5FileHash(File)
                Dim Dateiname As String = File.Replace(My.Computer.FileSystem.CurrentDirectory & "\", "")

                Label1.Text = "Aktuelle Datei: " & Dateiname
                Dim FirstElement As XmlElement = XmlDoc.CreateElement("Name")
                Dim SecondElement As XmlElement = XmlDoc.CreateElement("Hash")


                'retrieve the text
                Dim FirstTextElement As XmlText = XmlDoc.CreateTextNode(Dateiname)
                Dim SecondTextElement As XmlText = XmlDoc.CreateTextNode(Checksum)

                'append the nodes to the parentNode without the value
                ParentNode.AppendChild(FirstElement)
                ParentNode.AppendChild(SecondElement)


                'save the value of the fields into the nodes
                FirstElement.AppendChild(FirstTextElement)
                SecondElement.AppendChild(SecondTextElement)

            End If
        Next
        Label1.Text = "Erstellt!"
        'Save to the XML file
        XmlDoc.Save("demo.xml")

    End Sub

So sieht sie dann aus:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<PatchList>
  <PatchFiles>
    <Name>Mt2-Patchlistgenerator.pdb</Name>
    <Hash>C6722CC9358A4CE878DEEE212FFBC2DD</Hash>
    <Name>Mt2-Patchlistgenerator.vshost.exe</Name>
    <Hash>5A96850B84A268CA84018F1A9F6BB59</Hash>
    <Name>Mt2-Patchlistgenerator.vshost.exe.manifest</Name>
    <Hash>A19A2658BA69006AC9D11FD7D7E3C1</Hash>
    <Name>Mt2-Patchlistgenerator.xml</Name>
    <Hash>C1576D0781684F96BD2889DB09F876B</Hash>
    <Name>Patchlistgenerator by Kryter.exe</Name>
    <Hash>F34B16A592FA3D74F17EA62A48C09CF8</Hash>
    <Name>Patchlistgenerator by Kryter.pdb</Name>
    <Hash>7E5E0A11CCF1056D2FDC9B9EFF5E138</Hash>
    <Name>Patchlistgenerator by Kryter.xml</Name>
    <Hash>08E100ED60010140EDB81FABE7A9</Hash>
  </PatchFiles>
</PatchList>
Aussehen soll Sie aber so:

Code:
<?xml version="1.0" encoding="utf-8"?>
<PatchList>
  <PatchFiles>
    <PatchFile>
      <Name>local.eix</Name>
      <Hash>b83e83a8169acfe9b7a43191da2a7b3c</Hash>
    </PatchFile>
    <PatchFile>
      <Name>local.epk</Name>
      <Hash>b83e83a8169acfe9b7a43191da2a7b3c</Hash>
    </PatchFile>
    <PatchFile>
      <Name>pack\root.eix</Name>
      <Hash>1970e1498315995be5233bccc8042b4d</Hash>
    </PatchFile>
    <PatchFile>
      <Name>pack\root.epk</Name>
      <Hash>b83e83a8169acfe9b7a43191da2a7b3c</Hash>
    </PatchFile>
  </PatchFiles>
</PatchList>
Bitte Helft mir :/ Nutze den Source von Kryter und habe versucht ihn um zu scripten.

Niemand der Helfen kann ? :/
11/14/2015 13:39 Kraizy​#2
PHP Code:
Dim xmlDoc As New XmlDocument

Dim xmlDeclaration 
As XmlDeclaration xmlDoc.CreateXmlDeclaration("1.0""UTF-8"Nothing)
xmlDoc.AppendChild(xmlDeclaration)

Dim rootNode As XmlElement xmlDoc.CreateElement("PatchList")
xmlDoc.InsertBefore(xmlDeclarationxmlDoc.DocumentElement)
xmlDoc.AppendChild(rootNode)

Dim parentNode As XmlElement xmlDoc.CreateElement("PatchFiles")
xmlDoc.DocumentElement.PrependChild(parentNode)

For 
As Integer 1 To 5
     Dim fileNode 
As XmlElement xmlDoc.CreateElement("PatchFile")
     
parentNode.AppendChild(fileNode)

     
Dim xName As XmlElement xmlDoc.CreateElement("Name")
     
Dim xHash As XmlElement xmlDoc.CreateElement("Hash")

     
xName.AppendChild(xmlDoc.CreateTextNode("Name Nr." i))
     
xHash.AppendChild(xmlDoc.CreateTextNode("Hash Nr." i))

     
fileNode.AppendChild(xName)
     
fileNode.AppendChild(xHash)
Next 
Ausgabe:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<PatchList>
  <PatchFiles>
    <PatchFile>
      <Name>Name Nr.1</Name>
      <Hash>Hash Nr.1</Hash>
    </PatchFile>
    <PatchFile>
      <Name>Name Nr.2</Name>
      <Hash>Hash Nr.2</Hash>
    </PatchFile>
    <PatchFile>
      <Name>Name Nr.3</Name>
      <Hash>Hash Nr.3</Hash>
    </PatchFile>
    <PatchFile>
      <Name>Name Nr.4</Name>
      <Hash>Hash Nr.4</Hash>
    </PatchFile>
    <PatchFile>
      <Name>Name Nr.5</Name>
      <Hash>Hash Nr.5</Hash>
    </PatchFile>
  </PatchFiles>
</PatchList>
Musst halt nur noch dein Code für das Auslesen deiner Dateinamen/Hashes einfügen und die Schleife für dein Vorhaben anpassen.