Aspose.Tasks.Examples.CSharp.WorkingWithCalendars.CreatingUpdatingAndRemoving.ReplaceCalendarWithNewCalendar.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            try
            {				
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

                // ExStart:ReplaceCalendarWithNewCalendar
                // Create project
                Project project = new Project(dataDir + "Project5.mpp");

                // Access project calendars
                CalendarCollection calColl = project.Calendars;
                foreach (Calendar myCalendar in calColl)
                {
                    if (myCalendar.Name == "TestCalendar")
                    {
                        // Remove calendar
                        calColl.Remove(myCalendar);
                    }
                }

                // Add new calendar
                Calendar newCalendar = calColl.Add("TestCalendar");
                project.Save(dataDir + "ReplaceCalendar_out.mpp", SaveFileFormat.MPP);
                // ExEnd:ReplaceCalendarWithNewCalendar
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }
        }
    }
ReplaceCalendarWithNewCalendar