vCard.Net 2.1.0

dotnet add package vCard.Net --version 2.1.0                
NuGet\Install-Package vCard.Net -Version 2.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="vCard.Net" Version="2.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add vCard.Net --version 2.1.0                
#r "nuget: vCard.Net, 2.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install vCard.Net as a Cake Addin
#addin nuget:?package=vCard.Net&version=2.1.0

// Install vCard.Net as a Cake Tool
#tool nuget:?package=vCard.Net&version=2.1.0                

vCard.Net

vCard.Net is a .NET library designed to create, parse, and manipulate vCard files. vCards are electronic business cards that are widely used for sharing contact information.

Features

  • vCard Parsing: Easily parse vCard files and extract contact information.
  • vCard Generation: Generate vCard files with custom contact information.
  • vCard Properties: Support for a wide range of vCard properties like name, phone number, email, address, and more.
  • Serialization/Deserialization: Serialize vCard objects to text and deserialize vCard files into objects.
  • Cross-Platform: Works on .NET Core and .NET Framework.

Installation

To use vCard.Net in your project, install it via NuGet:

dotnet add package vCard.Net

Alternatively, you can clone this repository and build the project locally:

git clone https://github.com/gachris/vCard.Net.git
cd vCard.Net
dotnet build

Usage

Here’s a basic example to get you started with using vCard.Net:

Parsing a vCard file

using System;
using System.IO;
using System.Linq;
using vCard.Net.CardComponents;
using vCard.Net.Serialization;

// Read vCard data from a file
var filePath = "path/to/vCard_v21.vcf";
var vCardData = File.ReadAllText(filePath);

// Create a stream from the vCard data
using var memoryStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(vCardData));
using var reader = new StreamReader(memoryStream);

// Deserialize the vCard
var vCard = (VCard)SimpleDeserializer.Default.Deserialize(reader).First();

// Access some properties
Console.WriteLine(vCard.FormattedName);
Console.WriteLine(vCard.Emails.FirstOrDefault()?.Value);

Creating a vCard

using System;
using System.Collections.Generic;
using System.IO;
using vCard.Net.CardComponents;
using vCard.Net.DataTypes;
using vCard.Net.Serialization;

// Create a vCard
var vCard = new VCard
{
    Version = VCardVersion.vCard2_1,
    FormattedName = "John Doe",
    N = new StructuredName { GivenName = "John", FamilyName = "Doe" },
    Emails = new List<Email> 
    { 
        new Email 
        { 
            Value = "john.doe@example.com", 
            PreferredOrder = 1, 
            Types = new List<string> { "INTERNET" } 
        }
    }
};

// Serialize the vCard to a string
var serializer = new ComponentSerializer();
var vCardAsString = serializer.SerializeToString(vCard);

// Save the vCard to a file
var outputPath = "path/to/new_vcard.vcf";
File.WriteAllText(outputPath, vCardAsString);

// Output
Console.WriteLine("vCard saved to: " + outputPath);

Project Structure

  • vCardComponents: Core logic related to vCard properties and data types.
  • Collections: Data structures for managing vCard properties.
  • DataTypes: Defines the various vCard fields (e.g., Address, Email, Phone, etc.).
  • Serialization: Serialization and deserialization logic for vCard files.

Contributing

Contributions are welcome! Please follow these steps if you wish to contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Write clean, readable code and add comments where necessary.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on vCard.Net:

Package Downloads
iCloud.Dav.People

iCloud.Dav.People is a .NET library that allows you to interact with iCloud contacts and contact groups.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 82 11/15/2024
2.0.0 107 9/28/2024
1.0.2 424 4/5/2024
1.0.2-alpha 181 9/28/2023
1.0.1-alpha 365 12/23/2022
1.0.0-alpha 162 11/25/2022