中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > .NET > 临时文章
vCard Reader Class
作者:未知 时间:2004-11-13 12:12 出处:Blog 责编:chinaitpower
              摘要:暂无

Imports System.IO
Public Class vCardReader
#Region "Define"
    Public vCards As vCard()
#End Region
#Region "Subs"

    Sub New(ByVal vCardFileStream As FileStream)
        DecodeVCardFromFileStream(vCardFileStream)
    End Sub

    Private Function Split(ByVal Content As String) As CardProperty
        Dim CardProperty As CardProperty
        Dim PropertyAndParametreString As String = Content.Split(":")(0)
        Dim ValueString As String = Content.Split(":")(1)
        Dim Temp As String() = PropertyAndParametreString.Split(";")
        CardProperty.Name = Temp(0)
        If Temp.Length > 1 Then
            ReDim CardProperty.Parametres(Temp.GetUpperBound(0) - 1)
            Temp.Copy(Temp, 1, CardProperty.Parametres, 0, Temp.Length - 1)
        Else
            CardProperty.Parametres = Nothing
        End If
        CardProperty.Values = ValueString.Split(";")
        Return CardProperty
    End Function

    Public Sub DecodeVCardFromFileStream(ByVal vCardFileStream As FileStream)
        Dim Reader As New StreamReader(vCardFileStream)
        ReDim vCards(0)
        Dim CurrentVcard As Integer
        Do
            'Search for vCard
            ReDim vCards(CurrentVcard).Properties(-1)
            If InStr(Reader.ReadLine, "BEGIN:VCARD") Then
                'Start Processing vCard object
                Dim Content As String
                Dim cardProperty As CardProperty
                Do
                    Content = Reader.ReadLine
                    If Content = "END:VCARD" Then Exit Do
                    'The "=" in then end of a stream indicates message is not complete. Read next line and contact them.
                    Do

                        If Content.LastIndexOf("=") = Content.Length - 1 Then
                            Content = Content.Substring(1, Content.Length - 2) + Reader.ReadLine
                        Else : Exit Do
                        End If
                    Loop
                    'Split properties , parametres and values.
                    cardProperty = Split(Content)
                    Dim PropertyNumber As Integer = vCards(CurrentVcard).Properties.Length
                    ReDim Preserve vCards(CurrentVcard).Properties(PropertyNumber)
                    vCards(CurrentVcard).Properties(PropertyNumber) = cardProperty
                Loop
            End If
            If Reader.Peek() < 0 Then
                Return
            End If
            CurrentVcard += 1
            ReDim Preserve vCards(CurrentVcard)
        Loop
    End Sub
#End Region

#Region "Structures"
    Public Structure vCard
        Public Properties As CardProperty()
    End Structure

    Public Structure CardProperty
        Public Name As String
        Public Parametres() As String
        Public Values() As String
    End Structure

#End Region

End Class

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有