CAL文件中的问题 [英] Problem in CAL file
问题描述
我正在使用此代码创建用于员工请假的CAL文件.它从我的数据库中获取休假的开始日期和结束日期.例如,当使用以下方式通过电子邮件发送文件时,我遇到一个开始日期是6月5日而结束日期是6月7日的情况. MailMessage,我从来没有遇到任何问题,但是最近一次或两次使用它们会收到6月5日至6月8日的日期.
我虽然是PC问题,但与文件无关,但是当我使用记事本选择文件时,日期是5到8.当我从同一封电子邮件中打开同一文件时(因为我被抄送了),我是得到5比7.
出什么问题了?
//创建事件文件; if(!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"BlueFile")))) {Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"BlueFile"))); } file_name = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"BlueFile \\ Leave-Emp-" + employee_id.ToString()+.ics"); FileStream file_stream =新的FileStream(file_name,FileMode.OpenOrCreate); StreamWriter stream_writer =新的StreamWriter(file_stream); stream_writer.WriteLine("BEGIN:VCALENDAR"); stream_writer.WriteLine(版本:2.0"); 字符串strStart = dateFrom.DateTime.ToString("yyyyMMdd"); 字符串strEnd = dateTo.DateTime.AddDays(1).ToString("yyyyMMdd"); 字符串strSummary =休假-" + employee_name; 字符串strDesctiption ="; stream_writer.WriteLine("BEGIN:VEVENT"); stream_writer.WriteLine("SUMMARY:" + strSummary); stream_writer.WriteLine("DESCRIPTION:" + strDesctiption); stream_writer.WriteLine("DTSTART; VALUE = DATE:" + strStart); stream_writer.WriteLine("DTEND; VALUE = DATE:" + strEnd); stream_writer.WriteLine("END:VEVENT"); stream_writer.WriteLine("END:VCALENDAR"); stream_writer.Close(); file_stream.Close();
谢谢
更正::文件中的日期始终向所有用户显示6月8日,但数据库中的日期为6月7日,Outlook日历也显示6月7日.
>
Hi,
I am using this code to create a CAL file for the employees' leave. It takes the start date and end date for the leave from my database. For example, I have a case that the start date is 5 June and End date is 7 June... when sending the file by email using MailMessage, I never had any issue but recently with one or two uses they are receiving the dates from 5 Jun to 8 Jun.
I though it's a PC issues and nothing to do with the file but when I opned the file using notepad the date was 5 to 8.. when I open the same file from the same email (because I am CCed) I am getting 5 to 7.
What's the issue?
// create event file; if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlueFile"))) { Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlueFile")); } file_name = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlueFile\\Leave-Emp-" + employee_id.ToString() + ".ics"); FileStream file_stream = new FileStream(file_name, FileMode.OpenOrCreate); StreamWriter stream_writer = new StreamWriter(file_stream); stream_writer.WriteLine("BEGIN:VCALENDAR"); stream_writer.WriteLine("VERSION:2.0"); string strStart = dateFrom.DateTime.ToString("yyyyMMdd"); string strEnd = dateTo.DateTime.AddDays(1).ToString("yyyyMMdd"); string strSummary = "On Leave - " + employee_name; string strDesctiption = ""; stream_writer.WriteLine("BEGIN:VEVENT"); stream_writer.WriteLine("SUMMARY:" + strSummary); stream_writer.WriteLine("DESCRIPTION:" + strDesctiption); stream_writer.WriteLine("DTSTART;VALUE=DATE:" + strStart); stream_writer.WriteLine("DTEND;VALUE=DATE:" + strEnd); stream_writer.WriteLine("END:VEVENT"); stream_writer.WriteLine("END:VCALENDAR"); stream_writer.Close(); file_stream.Close();
Thanks,
CORRECTION: The date in the file is always showing 8 Jun to all users but the date from the database is 7 June and Outlook Calendar is showing 7 June as well
这篇关于CAL文件中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!