本文介绍了使用asp.net导入.ics文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我想将日历事件导入我的数据库.为此,我从Google日历,Hotmail日历,yahoo日历等导出了.ics文件.但是这些文件不是以相同的格式导入事件,所有这些日历是否都有任何组合代码.这是我使用的代码

Hi..

i want to import calendar events to my database. for that i exported .ics files from google calendar, Hotmail calendar,yahoo calendar and so on. but these files are not in same format to import events is there any combined code for all these calendars.This is the code which i used

FileStream fs = new FileStream(@"C:\HotMailCalendar.ics", FileMode.Open, FileAccess.Read);
  StreamReader sr = new StreamReader(fs);
            string ical = sr.ReadToEnd();
            char[] delim = { '\n' };
            string[] lines = ical.Split(delim);
            delim[0] = ':';
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].Contains("BEGIN:VEVENT"))
                {
                    string[] eventData = new string[9];
                    for (int j = 0; j < 9; j++)
                        eventData[j] = lines[i + j + 1].Split(delim)[1];
                    string strDate = eventData[0].ToString();
                    strDate = strDate.Replace("\r", "");

                    string format;
                    DateTime result;
                    CultureInfo provider = CultureInfo.InvariantCulture;
                   format = "yyyyMMddThhmmssssZ";
                  result = DateTime.ParseExact(strDate, format, provider);
                 i += 10;
              }
          }
          sr.Close();


在此先感谢...


thanks in advance...

推荐答案



这篇关于使用asp.net导入.ics文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 15:45