Following example will explains about how to get the document items inside the Folder in a SharePoint document library.
public DataTable GetDocItem(string folderName)
try
{
using (SPSite oSpSite = new SPSite(SPContext.Current.Web.Url, SPContext.Current.Site.SystemAccount.UserToken))
{
using (SPWeb oWeb = oSpSite.OpenWeb(SPContext.Current.Web.ID))
{
SPList spList = oWeb.Lists.TryGetList("XX");
dtSpData = new DataTable();
if (spList != null)
{
SPQuery oQuery = new SPQuery();
SPFolder oFolder = spList.RootFolder.SubFolders[folderName];
oQuery.Folder = oFolder;
dtSpData = spList.GetItems(oQuery).GetDataTable();
}
}
}
return dtSpData;
}
catch (Exception ex)
{
throw ex;
}
public DataTable GetDocItem(string folderName)
try
{
using (SPSite oSpSite = new SPSite(SPContext.Current.Web.Url, SPContext.Current.Site.SystemAccount.UserToken))
{
using (SPWeb oWeb = oSpSite.OpenWeb(SPContext.Current.Web.ID))
{
SPList spList = oWeb.Lists.TryGetList("XX");
dtSpData = new DataTable();
if (spList != null)
{
SPQuery oQuery = new SPQuery();
SPFolder oFolder = spList.RootFolder.SubFolders[folderName];
oQuery.Folder = oFolder;
dtSpData = spList.GetItems(oQuery).GetDataTable();
}
}
}
return dtSpData;
}
catch (Exception ex)
{
throw ex;
}
0 comments:
Post a Comment