Windows Phone:解析 VCard 字符串 [英] Windows Phone: Parse a VCard String
问题描述
我有一个 VCard 字符串,我想对其进行解析并插入到手机的联系人存储中.我检查了这个链接 http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207024(v=vs.105).aspx#BKMK_UsingtheRemoteIdHelperclass
I have a VCard String that I want to parse and insert to the phone's contacts store. I checked this link http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207024(v=vs.105).aspx#BKMK_UsingtheRemoteIdHelperclass
并找到以下方法
ContactInformation info = await ContactInformation.ParseVcardAsync(IInputStream vcard);
如何将我的 VCard 字符串转换为 IInputStream 以便我可以解析它?
how can I convert my VCard String to an IInputStream so that I can parse it ?
谢谢
推荐答案
好的,我找到了:
我们将使用 WindowsRuntimeStreamExtensions 类将 System.IO Streams 转换为Windows.Storage.Streams 对象:
We'll use the WindowsRuntimeStreamExtensions class to convert the System.IO Streams to the Windows.Storage.Streams objects:
System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(VCardDataString));
IInputStream input= System.IO.WindowsRuntimeStreamExtensions.AsInputStream(ms);
ContactInformation info = await ContactInformation.ParseVcardAsync(input);
StoredContact phoneContact = new StoredContact(store, info);
这篇关于Windows Phone:解析 VCard 字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!