I have the following code in my application. It is throwing
FileNotFound exception at `web.GetList("Lists/TestList")
This list exists and I am able to get the list from web.Lists.TryGetList("TestList")
. But I am getting exception when I am trying to get the list from the relative URL. Can anyone please help me?
string siteUrl = "<siteURL>";
using (SPSite site = new SPSite(siteUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.GetList("/Lists/TestList");
}
}
GetList
requires the full url as far as I can rememberlist.RootFolder.ServerRelativeUrl
. msdn.microsoft.com/EN-US/library/…