/// <summary> /// Parse the supplied byte array containing UTF-8 encoded vCard information (= vcf data) into a /// Windows Phone ContactInformation class (the ContactData property). /// </summary> /// <param name="vCardByte">UTF-8 encoded byte array that contains the vCard data to parse.</param> /// <returns>Task to await completion of the operation.</returns> public async Task ParseDataToContact(byte[] vCardByte) { var ms = new System.IO.MemoryStream(vCardByte); var input = System.IO.WindowsRuntimeStreamExtensions.AsInputStream(ms); // Find out vCard version (not done automatically) var vCardVersionPattern = new Regex(@"^VERSION:(?<vcvers>.+)$", RegexOptions.Multiline); var vCardVersionMatch = vCardVersionPattern.Match(Encoding.UTF8.GetString(vCardByte, 0, vCardByte.Length)); if (vCardVersionMatch.Success) { var vCardVersion = vCardVersionMatch.Groups["vcvers"].Value; VCardFormatToWrite = vCardVersion.Trim().Equals("2.1") ? VCardFormat.Version2_1 : VCardFormat.Version3; } // Parse vCard ContactData = await ContactInformation.ParseVcardAsync(input); }