Skip to content

bolorundurowb/vCardLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vCardLib

NuGet Badge Coverage Status NET Standard NET Standard License: MIT


This master branch contains the latest changes and features (which are breaking) to see the last major release ( v4) click here

This library supports reading multiple contacts from a single vcf file, a stream or a contact string and returns the contact objects in an Enumerable. The library currently supports only vCard version 2.1 and 3.0 (a curated list of properties supported can be seen on the documentation site).

How to use the library:

First get this package from nuget via your package manager:

Install-Package vCardLib.dll

or

dotnet add package vCardLib.dll

For Deserialization

Deserialize from a file

string filePath = // path to vcf file;
IEnumerable<vCard> contacts = vCardDeserializer.FromFile(filePath);

Deserialize from a Stream

var stream = // generate stream containing serialized vcards
IEnumerable<vCard> contacts = vCardDeserializer.FromStream(stream);

Deserialize from a string

var contactDetails = @"BEGIN:VCARD
VERSION:2.1
N:John;Doe;;;
END:VCARD";
IEnumerable<vCard> contacts = vCardDeserializer.FromContent(contactDetails);

For Serialization

Serialize as string

var vcard = new vCard(vCardVersion.v2)
{
    FormattedName = "John Doe"
};
var serialized = vCardSerializer.Serialize(vcard);

/*
BEGIN:VCARD
VERSION:2.1
REV:20230719T001838Z
FN:John Doe
END:VCARD
 */

Serialize with an override

This allows a vcard to get serialized to a different version

var vcard = new vCard(vCardVersion.v2)
{
    FormattedName = "John Doe"
};
var serialized = vCardSerializer.Serialize(vcard, vCardVersioon.v4);

/*
BEGIN:VCARD
VERSION:4.0
REV:20230719T001838Z
FN:John Doe
END:VCARD
 */

Contributors

A huge thank you to these wonderful people who took time to contribute to this project.


@bolorundurowb, @crowar , @rmja, @JeanCollas