I am currently working with an app that should load various info on a very specific zip file which contains the XML config file, using the DotNetZip library on C#, here's the code:
public static void InitializeData(string configFilePath)
{
if (File.Exists(configFilePath))
{
using (ZipFile zip1 = ZipFile.Read(configFilePath))
{
zipEntriesCount = zip1.Count;
if (zip1.ContainsEntry(installConfigFileName))
{
var entries = zip1.SelectEntries(installConfigFileName);
ZipEntry[] entriesArray = new ZipEntry[entries.Count];
entries.CopyTo(entriesArray, 0);
entriesArray[0].Extract(installConfigStream);
installConfigData = StreamToString(installConfigStream);
XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object
xmlDoc.Load(installConfigStream); // Load the XML document from the specified file
// Get elements
XmlNodeList XmlAppTitle = xmlDoc.GetElementsByTagName("appTitle");
XmlNodeList XmlAppCompany = xmlDoc.GetElementsByTagName("appCompany");
XmlNodeList XmlAppIconPath = xmlDoc.GetElementsByTagName("appIconPath");
XmlNodeList XmlAppLargeIconPath = xmlDoc.GetElementsByTagName("appLargeIconPath");
// Store app config data globally
// eg: globalVar = XmlVar[0].InnerText;
appTitle = XmlAppTitle[0].InnerText;
appCompany = XmlAppCompany[0].InnerText;
appIconPath = XmlAppIconPath[0].InnerText;
appLargeIconPath = XmlAppLargeIconPath[0].InnerText;
}
}
}
}
My question is, is there any better/more compact way of reaching same functionality?