微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 我创建的DateTime对象和DateTime.Now之间的差异

我正在尝试使用Exchange 2007 API查询特定用户的日历可用性.我的示例代码产生以下异常:

The time duration specified for FreeBusyViewOptions.TimeWindow is
invalid.

这是示例代码

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

service.AutodiscoverUrl("email@domain.com");

DateTime startTime = new DateTime(2012,1,6,7,0);

TimeWindow tw = new TimeWindow(startTime,startTime.AddHours(8));

GetUserAvailabilityResults result = service.GetUserAvailability(new List<AttendeeInfo> { new AttendeeInfo("email@domain.com") },tw,AvailabilityData.FreeBusyAndSuggestions);

奇怪的是,如果我用以下内容替换我的startTime赋值它可以工作:

DateTime startTime = DateTime.Now;

我创建的DateTime对象与DateTime.Now生成的对象之间有什么区别.我在调试时仔细检查了它们,但找不到区别.

有任何想法吗?

解决方法

这实际上似乎是GetUserAvailability方法中的一个问题,而不是任何DateTime操作.

根据MSDN documentation

The GetUserAvailability(Generic,TimeWindow,AvailabilityData,AvailabilityOptions) method supports only time periods that are a minimum of 24 hours long and that begin and end at 12:00a.m. To restrict the results of the method to a shorter time period,you must filter the results on the client.

原文地址:https://www.jb51.cc/csharp/98344.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐