I want to get the windows update patch's download url,and my code is
var session = new UpdateSession();
var searcher = session.CreateUpdateSearcher();
var searchType = "Type='Software' and IsInstalled =0";
searcher.Online = false;
var searchResult = searcher.Search(searchType);
var collection = searchResult.Updates;
foreach (IUpdate item in collection)
{
outpu("Title: \t{0}", item.Title);
outpu("UpdateId: \t{0}", item.Identity.UpdateID);
outpu("Description: \t{0}", item.Description);
if (item.KBArticleIDs[0] == "2592687")
{
Trace.WriteLine("what");
}
if ((item.BundledUpdates.Count > 0) && (item.BundledUpdates[0].DownloadContents.Count >0))
outpu("DownloadUrl: \t{0}", item.BundledUpdates[0].DownloadContents[0].DownloadUrl);
}
normally i can get the download url ,but sometimes i could not. For example ,when
KBArticleIDs = "2592687"
debug shows that "DownloadContents" has no child, so what should i do?