Sign in to follow this  
Followers 0
dazza

FileGetTime

8 posts in this topic

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.

Share this post


Link to post
Share on other sites



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)

When the words fail... music speaks

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#5 ·  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

When the words fail... music speaks

Share this post


Link to post
Share on other sites

$path = "C:\Program Files\Combat\Combat\"
$search = FileFindFirstFile($path & "syslog*")
While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $t = FileGetTime($path & $file,0,0)
    If @ERROR Then MsgBox(0,"","Error getting time from file:" & @CRLF & $file)
    MsgBox (0, $file, $t[2])
WEnd

This works!

I cannot see why but hell, it does. Many thanks!

:P

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

You weren't supplying the full path to the file for FileGetTime...

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0