VcfReaderReadToEnd Method

Returns an IEnumerableT of VCard objects that can be used to iterate over the VCF contents.

Definition

Namespace: FolkerKinzel.VCards
Assembly: FolkerKinzel.VCards (in FolkerKinzel.VCards.dll) Version: 8.0.1+a91cc3f0fd39aeb548e16006a60ca9dd10a304a2
C#
public IEnumerable<VCard> ReadToEnd()

Return Value

IEnumerableVCard
An IEnumerableT of VCard objects.

Remarks

Unlike the methods of the Vcf class, the Dereference(IEnumerableVCard) method is not called on the return value. The AnsiFilter class cannot be used by VcfReader either.

If possible, use the Vcf class if it is justifiable to keep the parsed content completely in memory. The utility of the VcfReader class is to read huge files.

Example

C#
using FolkerKinzel.VCards;

namespace Examples;

public static class VcfReaderExample
{
    // Reads a very large VCF file whose contents cannot be
    // completely held in memory.
    public static void Example(string filePath)
    {
        using var textReader = new StreamReader(filePath);
        using var reader = new VcfReader(textReader);

        IEnumerable<VCard> result = reader.ReadToEnd();

        Console.WriteLine("The file \"{0}\" contains {1} vCards.",
                          Path.GetFileName(filePath),
                          result.Count());
    }
}

/*
Console Output:

The file "LargeFile.vcf" contains 1000 vCards.
*/

Exceptions

IOExceptionCould not read from the source.

See Also