vCardLib is a .NET library to help developers read either single or multiple contacts from a single vcf file or StreamReader.
$ dotnet add package vCardLib.dllThis library provides functionality for working with vCard files.
Features:
IEnumerable object for easy iteration.Branches:
Important: The master branch may contain unstable code and is not recommended for production use.
Improvements:
master branch and provided a link to the latest stable release.master branch.I hope this improved markdown is helpful!
First get this package from nuget via your package manager:
Install-Package vCardLib.dll
or
dotnet add package vCardLib.dll
<br/>
string filePath = // path to vcf file;
IEnumerable<vCard> contacts = vCardDeserializer.FromFile(filePath);
var stream = // generate stream containing serialized vcards
IEnumerable<vCard> contacts = vCardDeserializer.FromStream(stream);
var contactDetails = @"BEGIN:VCARD
VERSION:2.1
N:John;Doe;;;
END:VCARD";
IEnumerable<vCard> contacts = vCardDeserializer.FromContent(contactDetails);
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
*/
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
*/
A huge thank you to these wonderful people who took time to contribute to this project.