Jump to content

Recommended Posts

Posted

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

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
Posted

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
Posted

$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!"

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...