Here i am trying to give an example to read iCal file which had uploaded in one document library.
Dim _listFile As SPList = web.Lists("Your Document Library")
Dim _listItemFiles As SPListItemCollection = _listFile.Items
For Each _item In _listItemFiles
Dim _spFile As SPFile = _item.File
Dim sr As New StreamReader(_spFile.OpenBinaryStream())
Dim ical As String = sr.ReadToEnd()
Dim delim As Char() = {ControlChars.Lf}
Dim lines As String() = ical.Split(delim)
For i As Integer = 0 To lines.Length - 1
If lines(i).Contains("BEGIN:VEVENT") Then
Dim eventData As String() = New String(11) {}
For j As Integer = 0 To 10
Dim splt As String() = lines(i + j + 1).Split(":")
If splt.Length > 1 Then
eventData(j) = splt(1).ToString()
End If
Next
Dim strDate As String = eventData(0).ToString().Trim() 'start Date
Dim endDate As String = eventData(1).ToString().Trim() 'end Date
Dim title As String = eventData(10).ToString() 'Title
strDate = strDate.Replace(vbCr, "")
Dim format As String
Dim result As DateTime
Dim lastDate As DateTime
Dim provider As CultureInfo = CultureInfo.InvariantCulture
format = "yyyyMMdd"
result = DateTime.ParseExact(strDate, format, provider)
lastDate = DateTime.ParseExact(endDate, format, provider)
End If
Next
Next
Dim _listFile As SPList = web.Lists("Your Document Library")
Dim _listItemFiles As SPListItemCollection = _listFile.Items
For Each _item In _listItemFiles
Dim _spFile As SPFile = _item.File
Dim sr As New StreamReader(_spFile.OpenBinaryStream())
Dim ical As String = sr.ReadToEnd()
Dim delim As Char() = {ControlChars.Lf}
Dim lines As String() = ical.Split(delim)
For i As Integer = 0 To lines.Length - 1
If lines(i).Contains("BEGIN:VEVENT") Then
Dim eventData As String() = New String(11) {}
For j As Integer = 0 To 10
Dim splt As String() = lines(i + j + 1).Split(":")
If splt.Length > 1 Then
eventData(j) = splt(1).ToString()
End If
Next
Dim strDate As String = eventData(0).ToString().Trim() 'start Date
Dim endDate As String = eventData(1).ToString().Trim() 'end Date
Dim title As String = eventData(10).ToString() 'Title
strDate = strDate.Replace(vbCr, "")
Dim format As String
Dim result As DateTime
Dim lastDate As DateTime
Dim provider As CultureInfo = CultureInfo.InvariantCulture
format = "yyyyMMdd"
result = DateTime.ParseExact(strDate, format, provider)
lastDate = DateTime.ParseExact(endDate, format, provider)
End If
Next
Next
No comments:
Post a Comment