AnsweredAssumed Answered

Remove old ProjectItem

Question asked by mjk5000 on Dec 5, 2019
Latest reply on Dec 11, 2019 by jbarrette-esristaff

I need to find a way to remove old Layouts from my project if they were added before a certain date.  I create layout templates and add them to my addin.  These templates are then used to print a map, however, after it is loaded I stays with the project.  I do want the layout to stay with the project (as load times are much faster), but when I update the Layout I want to remove the existing template if it is before a certain date that I maintain.  I need to be able to get the date the existing Layout was added to the Projects catalog, then I will remove it based on this date if it is old.

 

//Remove the old templates that might be out of date
                    foreach (LayoutProjectItem layoutTemplate in Project.Current.GetItems<LayoutProjectItem>())
                    {
//NEED LOGIC HERE TO SEE IF THE layoutTemplate IS BEFORE a DATE
                        Project.Current.RemoveItem(layoutTemplate as IProjectItem);
                    }

Outcomes