thanks to author @ http://blogs.tamtam.nl/appie/2009/02/23/Getting+ParentFolder+From+A+Custom+List.aspx
we can use the following method to get parent folder of listitem
we can use the following method to get parent folder of listitem
static
SPFolder GetParentFolder(SPListItem itemToFind,
SPFolder folder)
{
SPQuery query =
new
SPQuery();
query.Folder =
folder;
SPListItemCollection
items =
itemToFind.ParentList.GetItems(query);
foreach
(SPListItem item in
items)
{
if
(item.ID
==
itemToFind.ID)
{
return
(folder);
}
if
(item.Folder !=
null)
{
SPFolder resultFolder =
GetParentFolder(itemToFind,
item.Folder);
if
(resultFolder !=
null)
{
return
(resultFolder);
}
}
}
return
(null);
}
So adding that function allows
you to get a parentfolder with:
SPFolder parentFolder
= GetParentFolder(item, null);