Skip to content

Commit d8f87d1

Browse files
CopilotBornToBeRoot
andcommitted
Use InvariantCulture and specific exception handling
Co-authored-by: BornToBeRoot <[email protected]>
1 parent 7388f0b commit d8f87d1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Source/NETworkManager.Settings/SettingsManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,15 @@ private static DateTime ExtractTimestampFromFilename(string filePath)
342342
var timestampString = fileName.Substring(0, 14);
343343

344344
// Parse the timestamp
345-
if (DateTime.TryParseExact(timestampString, "yyyyMMddHHmmss", null,
345+
if (DateTime.TryParseExact(timestampString, "yyyyMMddHHmmss",
346+
System.Globalization.CultureInfo.InvariantCulture,
346347
System.Globalization.DateTimeStyles.None, out var timestamp))
347348
{
348349
return timestamp;
349350
}
350351
}
351352
}
352-
catch
353+
catch (ArgumentException)
353354
{
354355
// If any error occurs, return MinValue to sort this file as oldest
355356
Log.Warn($"Failed to extract timestamp from filename: {filePath}");

0 commit comments

Comments
 (0)