-
Notifications
You must be signed in to change notification settings - Fork 233
Deserialize an ics file
Rian Stockbower edited this page Jul 23, 2016
·
5 revisions
It's somewhat unusual for an ics file to have more than one VCALENDAR within it, but it is allowed. Due to the container-like capabilities of an ics file, loading one produces a CalendarCollection
instead of a single Calendar
. In most use cases, there will only be one Calendar
within that collection.
This example shows the most common use case, with one Calendar
inside a CalendarCollection
. We'll use LINQ to "reach inside" the each collection, and take the first event.
var calendarCollection = Calendar.LoadFromFile(@"path\to\file.ics");
//A VCALENDAR may contain many VEVENTs, so get the first calendar's first event
var firstEvent = calendarCollection
.First()
.Events
.First();