API call to get item from Url

Jun 1, 2009 at 7:55 AM

 SPListItem i = web.GetListItem( docUrl);

 

      using (SPSite site = new SPSite(docUrl))
        {
            using (SPWeb web = site.OpenWeb())
            {
                try
                {
    
                    web.AllowUnsafeUpdates = true;
                    SPListItem i = web.GetListItem( docUrl);
                    foreach(SPForm f in i.ParentList.Forms){
                        if(f.Type==PAGETYPE.PAGE_DISPLAYFORM){
                            destUrl=web.Url +"/"+f.Url  +"?ID="+i.ID;
                            break; 
                        }  
                    }
                }
                catch (Exception ex)
                {
                    ;
                }

            }

        }