string FolderName = "Peak";
using (SPWeb web = site.OpenWeb())
{
SPList oList = web.Lists["YourListName"];
using (SPWeb web = site.OpenWeb())
{
SPList oList = web.Lists["YourListName"];
SPListItemCollection collListItems = null;
foreach (SPFolder subFolder in oList.RootFolder.SubFolders)
{
if (subFolder.Name.ToLower() == FolderName.ToLower().Trim())
{
SPQuery oQuery = new SPQuery();
oQuery.Query = "<OrderBy><FieldRef Name=’Modified’ Ascending=’False’ /></OrderBy>";
oQuery.Folder = subFolder;
collListItems = oList.GetItems(oQuery);
break;
}
}
}
foreach (SPFolder subFolder in oList.RootFolder.SubFolders)
{
if (subFolder.Name.ToLower() == FolderName.ToLower().Trim())
{
SPQuery oQuery = new SPQuery();
oQuery.Query = "<OrderBy><FieldRef Name=’Modified’ Ascending=’False’ /></OrderBy>";
oQuery.Folder = subFolder;
collListItems = oList.GetItems(oQuery);
break;
}
}
}
No comments:
Post a Comment