获取SPListItem对象所在的SPFolder
/// <summary>
/// 获取SPListItem对象所在的SPFolder
/// </summary>
/// <param name="item">SPListItem对象</param>
/// <returns>SPListItem对象所在的SPFolder</returns>
public static SPFolder GetItemsFolder(SPListItem item)
{
string dirPath = SPUtility.GetUrlDirectory(item.Url);
SPList list = item.ParentList;
if(list.ParentWeb.ServerRelativeUrl!="/")
dirPath=string.Format("{0}/{1}",list.ParentWeb.ServerRelativeUrl,dirPath);
SPListItem folderItem = list.ParentWeb.GetListItem(dirPath);
if (folderItem != null)
return folderItem.Folder;
else
return null;
}