Victor Charles
asked on
Help with merging files
Hi,
I'm using the code below to merge file for multiple countries, how do I modify it to avoid duplicating the code for each country?
I'm using the code below to merge file for multiple countries, how do I modify it to avoid duplicating the code for each country?
fsItem= New System.IO.FileStream(Application.StartupPath + "\LinkFiles\LinkFinalMain.xml", IO.FileMode.Open)
dtsetItem.Clear()
dtsetItem.ReadXml(fsItem)
fsItem.Close()
Dim DestinationPath As String = IO.Path.Combine(Application.StartupPath + "\LinkFiles\", IO.Path.GetFileName("\LinkFiles\LinkFinalBEL.xml"))
If IO.File.Exists(DestinationPath) Then
fsReceiver = New System.IO.FileStream(Application.StartupPath + "\LinkFiles\LinkFinalBEL.xml", IO.FileMode.Open)
dtsetReceiver.Clear()
dtsetReceiver.ReadXml(fsReceiver)
dtsetItem.Merge(dtsetReceiver, True, MissingSchemaAction.AddWithKey)
End If
' MsgBox(dtsetItem.Tables(0).Rows.Count)
Dim DestinationPathA As String = IO.Path.Combine(Application.StartupPath + "\LinkFiles\", IO.Path.GetFileName("\LinkFiles\LinkFinalCAN.xml"))
If IO.File.Exists(DestinationPathA) Then
fsDonor = New System.IO.FileStream(Application.StartupPath + "\LinkFiles\LinkFinalCAN.xml", IO.FileMode.Open)
dtsetDonor.Clear()
dtsetDonor.ReadXml(fsDonor)
fsDonor.Close()
dtsetItem.Merge(dtsetDonor, True, MissingSchemaAction.AddWithKey)
End If
Dim DestinationPathB As String = IO.Path.Combine(Application.StartupPath + "\LinkFiles\", IO.Path.GetFileName("\LinkFiles\LinkFinalCZE.xml"))
If IO.File.Exists(DestinationPathB) Then
fsDonor = New System.IO.FileStream(Application.StartupPath + "\LinkFiles\LinkFinalCZE.xml", IO.FileMode.Open)
dtsetDonor.Clear()
dtsetDonor.ReadXml(fsDonor)
fsDonor.Close()
dtsetItem.Merge(dtsetDonor, True, MissingSchemaAction.AddWithKey)
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You, I will try it and get back to you.
ASKER
Thank You.
Open in new window
and then change all the references from dtsetReceiver to dt(iCountry).