Sign in to follow this  
Followers 0
E1M1

How is Autoit FileFindNextFile made?

6 posts in this topic

Is it just FindNextFile? or something other? I tried to list files with C++.

hFind = FindFirstFile(token, &FindFileData);
do{
_tprintf (TEXT("File Found: %s\n"),FindFileData.cFileName);
}while(FindNextFile(hFind, &FindFileData));
FindClose(hFind);

but it doesn't seem to work. With "C:\users\rain" it says what you can see below, but actually I have many files and folders in C:\Users\rain.

C:\Users\rain>D:\Development\Cplusplus\del\del2\Debug\del2.exe
C:\users\rain
File Found: rain

C:\Users\rain>

Iam just wondering if there's any alternative methods.


edited

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think you need to suffix a folder name with a wildcard (*.*) to list its contents. AutoIt probably does that automatically before doing the actual call.

Edited by danielkza

Share this post


Link to post
Share on other sites

The AutoIt source is at the download page.

Is it just FindNextFile? or something other?

Why would it be something other when AutoIt give the exact same result? :blink:

@danielkza

You make no sense.

Share this post


Link to post
Share on other sites

The AutoIt source is at the download page.

Why would it be something other when AutoIt give the exact same result? :blink:

@danielkza

You make no sense.

I wouldn't be surprised if AutoIt did some processing on the string before passing it to the actual API calls. Apparently, that isn't the case: a FileFindFirstFile search, when passed a string without wildcards, returns it as the single result.

All that doesn't change the fact that if you want to list directory contents, you need to append an actual wildcard to the pattern. You can check it yourself:

ConsoleWrite("=== FileFindFirstFile('C:\') ===" & @CRLF)

$hSearch = FileFindFirstFile("C:\")
$File = FileFindNextFile($hSearch)
While Not @error
    ConsoleWrite($File & @CRLF)
    $File = FileFindNextFile($hSearch)
WEnd

ConsoleWrite("=== FileFindFirstFile('C:\*.*') ===" & @CRLF)

$hSearch = FileFindFirstFile("C:\*.*")
$File = FileFindNextFile($hSearch)
While Not @error
    ConsoleWrite($File & @CRLF)
    $File = FileFindNextFile($hSearch)
WEnd

Share this post


Link to post
Share on other sites

hey it worked. thanks alot


edited

Share this post


Link to post
Share on other sites

$hSearch = FileFindFirstFile("C:\*.*")
can also be
$hSearch = FileFindFirstFile("C:\*")
There is an old windows bug that makes it ignore the last dot astrick


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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