Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with creating Document Library in SharePoint

I got this error while creating a document library in sharepoint.

A list, survey, discussion board, or document library with the specified title already exists in this Web site. Please choose another title.

Here is my coding.

                SPSite site = new SPSite(url);
                SPWeb oWebsite = site.OpenWeb();
                oWebsite.AllowUnsafeUpdates = true;
                Guid customListID = oWebsite.Lists.Add(docLibraryName, docLibraryName, SPListTemplateType.DocumentLibrary);
                oWebsite.Update();
                oWebsite.AllowUnsafeUpdates = false;

Thanks.

UPDATE:

forget to mention that there is no such document library with the name I am trying to add.

like image 229
kevin Avatar asked Mar 03 '26 02:03

kevin


1 Answers

Use SharePoint designer and connect to that site. You may find that a folder with that name has been created which is causing the code to think that the list already exists. Delete that folder and you should be all set.

like image 58
k10 Avatar answered Mar 05 '26 15:03

k10