public override void DeletePackage(string packageId)
{
var files = Path.Combine(dataFolder, Constants.InstalledPackageFilesXml);
var packages = Path.Combine(dataFolder, Constants.InstalledPackagesXml);
var xmlDoc = new XmlDocument();
// remove files from packagefiles.xml
xmlDoc.Load(files);
var packageNodes = xmlDoc.SelectNodes("InstalledPackageFiles/item");
if(packageNodes != null && packageNodes.Count > 0)
{
for (int i = 0; i < packageNodes.Count; i++)
{
if (packageNodes[i].Attributes != null && packageNodes[i].Attributes["id"] != null)
{
if (packageId == packageNodes[i].Attributes["id"].InnerText)
{
if (packageNodes[i].ParentNode != null)
packageNodes[i].ParentNode.RemoveChild(packageNodes[i]);
}
}
}
}
xmlDoc.Save(files);
// remove packages from packages.xml
xmlDoc = new XmlDocument();
xmlDoc.Load(packages);
var pkg = xmlDoc.SelectSingleNode("//InstalledPackages/item[@id='" + packageId + "']");
if (pkg != null && pkg.ParentNode != null)
pkg.ParentNode.RemoveChild(pkg);
xmlDoc.Save(packages);
}