Sign in to follow this  
Followers 0
eJan

FileFindNextFile > encountered problem..

4 posts in this topic

AutoIt 3.1.1.56

Fixed : FileFindFirstFile does not return anymore "." or "..".

First run and everything works fine with script /FileFindNextFile/:

#NoTrayIcon

; Shows the filenames of all files in the current directory
$search = FileFindFirstFile(@ScriptDir & "\Favorites\*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)

Then I run this one with Favorites.rar:

$search = FileFindFirstFile(@ScriptDir & "\Favorites\*")

If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    If $file > "001" Then
        DirRemove(@ScriptDir & "\Favorites\001", 1)
        FileClose($search)
        Exit
    EndIf
WEnd

FileClose($search)
DirRemove(@ScriptDir & "\Favorites", 1)

and...Posted Image

Then I try the first one with empty "Favorites" folder and...Posted Image

Is this in my script or [Fixed : FileFindFirstFile does not return anymore "." or "..".]?

Share this post


Link to post
Share on other sites



FindFindFirstfile on empty dir corrected in 3.1.1.57

But not sure what is the remove crashing.

can you highlight when it occurs?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks jpm, I'm gonna try it right now.

EDIT:

FindFindFirstfile on empty dir corrected in 3.1.1.57

But not sure what is the remove crashing.

can you highlight when it occurs?

It occurs only in 3.1.1.56 when i run the script several times again, the error could be in my script but I cannot find the good way to finish it. Maybe some help, I'd like to check if folder contain 001 and some file with it, if yes then delete only 001, else remove complete $search dir (@ScriptDir & "\Favorites").

$search = FileFindFirstFile(@ScriptDir & "\Favorites\*")

If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    If $file > "001" Then
        DirRemove(@ScriptDir & "\Favorites\001", 1)
        FileClose($search)
        Exit
    Else
        DirRemove(@ScriptDir & "\Favorites", 1)
        FileClose($search)
        Exit
    EndIf
WEnd

FileClose($search)
Edited by eJan

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