Jump to content

FileGetTime


dazza
 Share

Recommended Posts

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.

Link to comment
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.

Link to comment
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

Link to comment
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
Link to comment
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($PATH & "\" & $FILE[$INDEX])
        MsgBox(0,$FILE[$INDEX],$TIME[2])
    Next
EndIf
Edited by Andreik

When the words fail... music speaks.

Link to comment
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

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...