Jump to content

Recommended Posts

Posted

Why does this code:

$search = FileFindFirstFile("C:\Program Files\Combat\Combat\syslog*")
    While 1
        $file = FileFindNextFile($search) 
        If @error Then ExitLoop
        $t = FileGetTime($file,0,0)
        msgbox (0, $file, $t[2])
    WEnd
    FileClose($search)

kick out:

U:\SLAG.au3 (55) : ==> Subscript used with non-Array variable.:

msgbox (0, $file, $t[2])

msgbox (0, $file, $t^ ERROR

I just want to check the last modified/created date of all files in a specified folder.

Posted

Why does this code:

$search = FileFindFirstFile("C:\Program Files\Combat\Combat\syslog*")
    While 1
        $file = FileFindNextFile($search) 
        If @error Then ExitLoop
        $t = FileGetTime($file,0,0)
        msgbox (0, $file, $t[2])
    WEnd
    FileClose($search)

kick out:

U:\SLAG.au3 (55) : ==> Subscript used with non-Array variable.:

msgbox (0, $file, $t[2])

msgbox (0, $file, $t^ ERROR

I just want to check the last modified/created date of all files in a specified folder.

Try this:

$path = FileSelectFolder("SELECT","")
$search = FileFindFirstFile($path & "\*.*")
While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $t = FileGetTime($file,0,0)
    msgbox (0, $file, $t[2])
WEnd
FileClose($search)
Posted

Try this:

$path = FileSelectFolder("SELECT","")
$search = FileFindFirstFile($path & "\*.*")
While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $t = FileGetTime($file,0,0)
    msgbox (0, $file, $t[2])
WEnd
FileClose($search)
Nope. Still the same error. :P
Posted (edited)

Or you can use FileListToArray:

#include <File.au3>
$PATH = FileSelectFolder("SELECT","")
$FILE = _FileListToArray($PATH,"*",1)
If IsArray($FILE) Then
    For $INDEX = 1 To $FILE[0]
        $TIME = FileGetTime($PATH & "\" & $FILE[$INDEX])
        MsgBox(0,$FILE[$INDEX],$TIME[2])
    Next
EndIf
Edited by Andreik
Posted

Or you can use FileListToArray:

#include <File.au3>
$PATH = FileSelectFolder("SELECT","")
$FILE = _FileListToArray($PATH,"*",1)
If IsArray($FILE) Then
    For $INDEX = 1 To $FILE[0]
        $TIME = FileGetTime($FILE[$INDEX])
        MsgBox(0,$FILE[$INDEX],$TIME[2])
    Next
EndIf

I'll add that to my arsenal. Many thanks.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...