FileNotFoundException 0x80070002

Using the in the the wrong parameter with the SPWeb.GetList method you will receive a FileNotFoundException with the following very SharePoint-ish error message:

System.IO.FileNotFoundException: <nativehr>0x80070002</nativehr>

The stacktrace will often give more information but the ULS log it wil simply show:


So the parameter is incorrect; Either the URL does not specify a valid path to the website, or the list does not exist in the website.

The GetList method gets the list that is associated with the specified server-relative URL to the root folder of a list, such as /sites/sitecollection/subsite/Lists/Announcements.


You can use the SPUrlUtility.CombineUrl with your webs server relative URL like this:

var list = web.GetList(SPUrlUtility.CombineUrl(web.ServerRelativeUrl, 
"lists/" + listFolderName));

I prefer to use the SPWeb.GetList over the SPWeb.Lists Property. Endusers can easy change the list title in the GUI but it is harder to change its URL.

Be aware; there are other methods casting System.IO.FileNotFoundException!