Import/Export to ICalendar
The RadScheduler allows for importing and exporting data to the ICalendar format. This is supported through the AppointmentCalendarImporter and AppointmentCalendarExporter classes.
AppointmentCalendarImporter
You can import data in the ICalendar format by using the AppointmentCalendarImporter. It exposes an Import method, which expects a TextReader object with the content that should be imported and returns a collection of IAppointment objects, which can be set to the AppointmentsSource of the RadScheduler.
Example 1: Using the AppointmentCalendarImporter
using (StreamReader reader = File.OpenText("myfile.ics"))
{
var importer = new AppointmentCalendarImporter();
var appointments = importer.Import(reader);
// "this.scheduler" refers to the RadScheduler instance that you are targeting
this.scheduler.AppointmentsSource = appointments;
}
AppointmentCalendarExporter
You can export the appointments from RadScheduler to a file in the ICalendar format with the help of the AppointmentCalendarExporter. You can use its Export method, which receives a collection of appointments and a TextWriter object.
Example 2: Using the AppointmentCalendarExporter
using (StreamWriter writer = File.CreateText("myfile.ics"))
{
var exporter = new AppointmentCalendarExporter();
// "this.scheduler" refers to the RadScheduler instance that you are targeting
var apps = this.scheduler.AppointmentsSource.OfType<Appointment>();
exporter.Export(apps, writer);
}
The AppointmentCalendarExporter and AppointmentCalendarImporter classes expose some useful virtual methods, which can be overriden in a derived class in cases where the import or export behavior needs to be customized.