对于 .ics 文件的导出,我编写了以下代码。折叠 | 复制代码
iCalendar iCal = new iCalendar();
foreach (DataRow row in dt.Rows)
{
// Create the event, and add it to the iCalendar
Event evt = iCal.Create<event>();
// Set information about the event
evt.Start = (DDay.iCal.iCalDateTime)Convert.ToDateTime(row["StartDate"]);
evt.End = (DDay.iCal.iCalDateTime)Convert.ToDateTime(row["EndDate"]);// This also sets the duration
evt.Description = (string)row["Description"];
}
// Serialize (save) the iCalendar
iCalendarSerializer serializer = new iCalendarSerializer();
serializer.Serialize(iCal, @"C:\iCalendar.ics");
它对我来说工作正常,但它会将文件写入 C 驱动器或按照我们给出的路径。但我需要它是可下载的。
我尝试了一些代码,但这不是我需要的确切格式。
提前致谢。