Meaning of exception in C# app: “Not a legal OleAut date”?

后端 未结 6 1965
暖寄归人
暖寄归人 2020-12-20 12:03

Does anyone know what this means. Getting this in C# winforms applications:

Not a legal OleAut date

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-20 12:48

    I've used:

    try
    {
        if (folderItem.ModifyDate.Year != 1899)
        {
            this.FileModifiedDate = folderItem.ModifyDate.ToShortDateString() + 
                " " +
                folderItem.ModifyDate.ToLongTimeString();
        }
    }
    //we need this because it throws an exception if it's an invalid date...
    catch (ArgumentException) { } 
    

    to deal with the same problem I'm having. It throws the exception when we check the year in my case. Doing nothing on an invalid date is exactly the behavior I want, so this hack works.

提交回复
热议问题