/// <summary> /// Saves the supplied calendar object as an iCalendar file at the supplied path. /// </summary> /// <param name="calendar">The calendar object to save.</param> /// <param name="path">The path to save the iCalendar file at.</param> /// <exception cref="System.ArgumentNullException">Thrown if a calendar is not provided, or a path was not provided.</exception> /// <returns>Always returns true. (The iCalendar serializer does not report whether it was successful.)</returns> public void SaveCalendar(Calendar calendar, string path) { // Check if a calendar and path was provided. if (calendar != null && !string.IsNullOrWhiteSpace(path)) { // A calendar and path was provided. // Create a serializer to save the iCalendar calendar file. DDay.iCal.Serialization.iCalendar.iCalendarSerializer serializer = new DDay.iCal.Serialization.iCalendar.iCalendarSerializer(); // Serialize the iCalendar calendar file to the path supplied. serializer.Serialize(ToIICalendar(calendar), path); } else { // A calendar or path not provided. if (calendar == null) { throw new ArgumentNullException("calendar"); } else { throw new ArgumentNullException("path"); } } }
public ActionResult TestIcal() { DDay.iCal.iCalendar calendario = new DDay.iCal.iCalendar(); DDay.iCal.Event evento = calendario.Create<DDay.iCal.Event>(); evento.Start = new DDay.iCal.iCalDateTime(System.DateTime.Now); evento.Summary = "Presentacion Demo"; evento.End = new DDay.iCal.iCalDateTime(System.DateTime.Now).AddHours(2); evento.GeographicLocation = new DDay.iCal.GeographicLocation(-33.372909, -70.581080); DDay.iCal.Serialization.iCalendar.iCalendarSerializer serializer = new DDay.iCal.Serialization.iCalendar.iCalendarSerializer(calendario); String ruta = Server.MapPath("..\\Content\\Eventos\\"); serializer.Serialize(ruta+"filename.ics"); return View(); }