Click here to Skip to main content
15,909,546 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
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
C#
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...
Posted
Updated 28-Aug-12 1:48am
v3
Comments
[no name] 27-Aug-12 9:07am    
http://www.codeproject.com/Articles/24213/How-to-Use-Google-and-Other-Tips-for-Finding-Progr
ZurdoDev 27-Aug-12 10:15am    
I am not familiar with any that will handle all formats so you may want to search google for that question or you'll need to write a method for each format.

 
Share this answer
 
check the opensource solution:
http://sourceforge.net/projects/icalparser/[^]
 
Share this answer
 
Comments
07405 28-Aug-12 2:17am    
i had gone through the site. i cant understand that can u suggest me how to solve it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900