Env
Win11pro 23H2
dotnet8
How to reproduce
- Change system date time format: Control Panel-> Region-> Additional Settings-> "Date" tab-> Short date.
- Change the "Short date" from "M/d/yyyy" to "M/d/yyyy/dddd" which will append the dayofweek, like "10/25/2024/Friday"
- Try to extract something by calling ArchiveFile.Extract
Expected
Extracted successfully.
Actual
System.FormatException was thrown
System.FormatException: String '' was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(ReadOnlySpan`1 s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.Convert.ToDateTime(String value, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at SevenZipExtractor.ArchiveFile.GetProperty[T](UInt32 fileIndex, ItemPropId name) in C:\Users\Andy\lab\ztmz_pacenote\src\SevenZipExtractor\SevenZipExtractor\ArchiveFile.cs:line 249
at SevenZipExtractor.ArchiveFile.GetPropertySafe[T](UInt32 fileIndex, ItemPropId name) in C:\Users\Andy\lab\ztmz_pacenote\src\SevenZipExtractor\SevenZipExtractor\ArchiveFile.cs:line 213
at SevenZipExtractor.ArchiveFile.get_Entries() in C:\Users\Andy\lab\ztmz_pacenote\src\SevenZipExtractor\SevenZipExtractor\ArchiveFile.cs:line 174
at SevenZipExtractor.ArchiveFile.Extract(Func`2 getOutputPath) in C:\Users\Andy\lab\ztmz_pacenote\src\SevenZipExtractor\SevenZipExtractor\ArchiveFile.cs:line 104
at SevenZipExtractor.ArchiveFile.Extract(String outputFolder, Boolean overwrite) in C:\Users\Andy\lab\ztmz_pacenote\src\SevenZipExtractor\SevenZipExtractor\ArchiveFile.cs:line 80
because in T result = (T)Convert.ChangeType(value.ToString(), underlyingType);, value.ToString() will output "10/25/2024/Friday 18:00:00", while this format cannot be parsed to DateTime by default. thus in method private T GetPropertySafe<T>(uint fileIndex, ItemPropId name), only InvalidCastException was handled, but FormatException was not. it's not safe now XD.
Env
Win11pro 23H2
dotnet8
How to reproduce
Expected
Extracted successfully.
Actual
System.FormatException was thrown
because in
T result = (T)Convert.ChangeType(value.ToString(), underlyingType);,value.ToString()will output "10/25/2024/Friday 18:00:00", while this format cannot be parsed to DateTime by default. thus in methodprivate T GetPropertySafe<T>(uint fileIndex, ItemPropId name), onlyInvalidCastExceptionwas handled, butFormatExceptionwas not. it's not safe now XD.