If you right click on a sub folder in a library and select Copy Shortcut.
How do you parse or use the Copy Shortcut value to CAML query the a single folder and its sub folders?
Copy Shortcut value:
http://sharepoint.com/siteName/LibraryName/Forms/AllItems.aspx?RootFolder=%2FsiteName%2FLibrary%20Name%2FFolderOne%2FFolder2&FolderCTID=0x01200065B0917E61502A4CB259DB83E8745555&View={D471308F-B032-4973-B7C2-56F75A6C8B46}
I'm working with a Visual Studio workflow along with SharePoint 2010.
edit / update
This is what I ended up with:
string sCopyFrom = http://sharepoint.com/siteName/LibraryName/Forms/AllItems.aspx?RootFolder=%2FsiteName%2FLibrary%20Name%2FFolderOne%2FFolder2&FolderCTID=0x01200065B0917E61502A4CB259DB83E8745555&View={D471308F-B032-4973-B7C2-56F75A6C8B46}
using (SPSite siteCollection = new SPSite(sCopyFrom))
{
using (SPWeb webSub = siteCollection.OpenWeb())
{
SPList copySource = webSub.GetListFromUrl(sCopyFrom);
string folderPath = sCopyFrom.Split(new string[] { "RootFolder=" }, StringSplitOptions.None)[1].Split('&')[0].Trim().Replace("%2F", "/").Replace("%20", " ").ToString(); ;
SPFolder targetFolder = webSub.GetFolder(folderPath);
// Query to get items
SPQuery query = new SPQuery();
query.RowLimit = 500;
query.ViewAttributes = "Scope=\"Recursive\"";
query.Folder = copySource.ParentWeb.GetFolder(targetFolder.UniqueId);
query.Query = "";
do
{
SPListItemCollection collListItems = copySource.GetItems(query);
foreach (SPListItem item in collListItems)
{
//work with item
}
query.ListItemCollectionPosition = collListItems.ListItemCollectionPosition;
} while (query.ListItemCollectionPosition != null);
}
}