I've created some code that identifies all of the site collections on a farm and then loops through all of the sites and lists within those collections . It's not ideal, but I've been tasked with it, and need to do so.
Unfortunately the code is performing very slowly, and I believe it's due to the following code which finds all of the items within a list:
foreach (SPList list in web.Lists) { query.RecordLists(list.ID.ToString(), list.Author.ToString(), list.Title, list.DefaultViewUrl, list.ParentWeb.Title, list.ParentWebUrl, list.ItemCount, list.LastItemModifiedDate, list.LastItemDeletedDate); // check if files exist in the document library, if they don't break out to next level if (list.ItemCount <= 0) continue; for (int i = 0; i < list.Items.Count; i++) { try { SPListItem item = list.Items[i]; if (!item["Created By"].ToString().Contains("System Account") && !item.Url.Contains("_catalogs") && !item.Url.Contains("Style Library") && !item.Url.Contains("Cache Profiles") && !item.ContentType.ToString().Contains("Theme Gallery") && !item.ContentType.ToString().Contains("Converted Forms") && !item.ContentType.ToString().Contains("Page Output Cache") && !item.ContentType.ToString().Contains("Master Page")) { query.RecordItems(item.ID.ToString(), item.ContentType.Name, item.DisplayName, item.Name, "", item.Url, item["Created By"].ToString(), "", Convert.ToDateTime(item["Modified"]), item["Modified By"].ToString(), Convert.ToDateTime(item["Created"]), item["Created By"].ToString()); } } catch (NullReferenceException) { SPListItem item = list.Items[i]; Logger.Error( "[{0}] Filed moving on file {1} as not all content was present", item.Name); } } } Is there a faster way to do this? At its current rate this will take hours to execute.