Для простой ситуации - нужно найти самый последний лог файл в папке с логами. Функция очень простая, но кому-то может и пригодиться
Код:
#cs
@error
1 = Log directory does not exist
2 = Function FileGetTime() returns error, @extended = @error for FileGetTime()
#ce
#include <File.au3>
Func _FindLatestLogFile($log_folder_path)
Local $log_file_array[1], $log_file_date_array[1]
Local $a, $latest_log_number, $latest_log_date
Local $error_text
$log_file_date_array[0] = 0
$latest_log_date = "00000000000000"
If Not(StringRight($log_folder_path, 1) == "\") Then
$log_folder_path = $log_folder_path & "\"
EndIf
If FileExists($log_folder_path) Then
$log_file_array = _FileListToArray($log_folder_path)
If $log_file_array = False Then
Switch @error
Case 1
$error_text = "Folder not found or invalid"
Case 2
$error_text = "Invalid $sFilter"
Case 3
$error_text = "Invalid $iFlag"
Case 4
$error_text = "No File(s) Found"
Case Else
$error_text = "Unknown error"
EndSwitch
MsgBox(0x10, "Alarm!", "Function FileGetTime() returns error: " & $error_text)
SetError(2, @error)
Return False
Else
For $a = 1 To UBound($log_file_array) - 1
ReDim $log_file_date_array[$a + 1]
$log_file_date_array[$a] = FileGetTime($log_folder_path & $log_file_array[$a], 0, 1)
$log_file_date_array[0] = $a
Next
EndIf
Else
Switch MsgBox(0x15, "Alarm!", "Log directory does not exist!")
Case 2
SetError(1)
Return False
Case 4
_FindLatestLogFile($log_folder_path)
EndSwitch
EndIf
For $a = 1 To UBound($log_file_date_array) - 1
If $log_file_date_array[$a] > $latest_log_date Then
$latest_log_number = $a
$latest_log_date = $log_file_date_array[$a]
EndIf
Next
Return $log_file_array[$latest_log_number]
EndFunc