Hot answers tagged

2

You need update folder metadata for the root folders after run the MoveTo method, modify the code as below. if (currentItem.ContentType.Name.ToLower().Contains("project")) { Console.WriteLine(currentItem["ID"]); SPFolder folder = omsWeb.GetFolder(omsWeb.ServerRelativeUrl + "/Shared Documents/"+currentItem["ID"].ToString()); var modified = folder....


1

Several things to try: Instead of foreach loops, switch them out for 'for' loops, they have been proven to be faster: https://www.c-sharpcorner.com/article/for-vs-foreach-in-c-sharp/ I'd look into concatenation of string more efficiently: https://stackoverflow.com/questions/21078/most-efficient-way-to-concatenate-strings I'd replace all instances of ...


1

I suggest to use SPListItemCollection class instead of DataTable. Please try: using (SPSite site = new SPSite("YOUR SITE URL")) using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists.TryGetList("Workflow Tasks"); var query = new SPQuery { Query = String.Format("<Where><Eq><FieldRef Name='{0}' /><Value Type='...


1

According to your source code you are creating a site collection then updating the related content database with a maximum site collection with one. That piece of code might work only one time for one web application if before you are not creating a new content database or incrementing the MaximumSiteCount by 1. So, before calling the SPSiteCollection.Add ...


Only top voted, non community-wiki answers of a minimum length are eligible