views:

273

answers:

1

I want to be able to read vCard and vCalendar data using .NET, I have something which does this, and have looked at the specification.
For those not familar with the format here is some test data from my current application:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Windows Calendar 1.0//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Greenwich Mean Time : Dublin\, Edinburgh\, Lisbon\, London
BEGIN:STANDARD
DTSTART:20001029T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:GMT Standard Time
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20000326T010000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZNAME:GMT Daylight Time
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DESCRIPTION:Upload ZuneCardr InTouch to the brand new ZuneCardr.com
DTSTAMP:20080120T135839Z
DTSTART;TZID="Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London":2008
 0318T140000
DTEND;TZID="Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London":200803
 18T150000
LOCATION:Internet
SUMMARY:ZuneCardr intouch
UID:D6969118-476F-4BB1-A71C-FC8D212F97CF
END:VEVENT
END:VCALENDAR

And a vCard

BEGIN:VCARD
VERSION:2.1
N:Planetoid;Rogue;Middle;Mr;
FN:Rogue Planetoid
ORG:Comentsys
TITLE:My Contact Title
NOTE;ENCODING=QUOTED-PRINTABLE:Stack Overflow
TEL;WORK;VOICE:020-000-11
TEL;HOME;VOICE:191-999-9999
TEL;CELL;VOICE:177-899-111
TEL;WORK;FAX:020-000-222
ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;Stack Overflow;Stack Overflow City;MO;98901;
ADR;HOME;ENCODING=QUOTED-PRINTABLE:;;Address;City;CO;90210;
EMAIL;PREF;INTERNET:[email protected]
REV:20030407T144607Z
End:VCARD

These are both stored as plain text, filename.ics for vCalendar and filename.vcf for vCard.
I currently use line by line parsing, however this seems primitive as iCalendar items can be multi-line could LINQ or similar method be used, such as those that cope with missing or extra elements, including carriage returns in the data?
I have the specifications for this, if a similar way is possible for something else then this will be fine, I am using .NET 3.5 and Visual Basic 2008, so can use any .NET feature available that could support this.

+2  A: 

Check this: http://www.codeproject.com/KB/dotnet/vCardReader.aspx

or try use Regular Expressions :)

pho3nix
Thanks for that link - must have missed that when I was searching codeproject for something like that. Hopefully a few more examples may be posted but will look at that one for sure.
RoguePlanetoid