public static string Delete(string filePath)
{
StringBuilder errors = new StringBuilder();
ConfiguredEndpointCollection collection = ConfiguredEndpointCollection.Load(filePath);
int loaded = 0;
int deleted = 0;
foreach (ConfiguredEndpoint endpoint in collection.Endpoints)
{
loaded++;
try
{
Delete(endpoint.ComIdentity.Clsid);
deleted++;
}
catch (Exception e)
{
if (errors.Length > 0)
{
errors.AppendFormat("\r\n");
}
errors.AppendFormat("Endpoint #{0} - {1}", loaded, e.Message);
}
}
if (errors.Length > 0)
{
errors.AppendFormat("\r\n\r\n{0} of {0} endpoints deleted successfully.", deleted, loaded);
}
return errors.ToString();
}