# WinApi & findNextFile

**URL:** <https://www.dynamicsuser.net/t/winapi-findnextfile/15114>\
**Category:** Developer Forum\
**Created:** [June 7, 2004, 10:48am UTC](https://www.dynamicsuser.net/t/winapi-findnextfile/15114 "2004-06-07T10:48:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bojan.jovicic](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@bojan.jovicic](https://www.dynamicsuser.net/u/bojan.jovicic)\
**Post date:** [June 7, 2004, 10:48am UTC](https://www.dynamicsuser.net/t/winapi-findnextfile/15114/1 "2004-06-07T10:48:45Z")

</div>

I have a problem with WinApi. I need to process all files from a directory. I am not sure if I am using this api calls correctly, but findNextFile doesn’t seem to work. Here is the sample code: // This works ok, i gets some number (possibly file handle), and str1 gets filename [i, str1] = WinApi::findFirstFile(fileName); // This doesn’t work, resulting in str1 = ‘’ str1 = WinApi::findNextFile(i);

---

<div class="post-metadata">

**Author:** ![Mugur](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Mugur](https://www.dynamicsuser.net/u/Mugur)\
**Post date:** [June 12, 2004, 3:22pm UTC](https://www.dynamicsuser.net/t/winapi-findnextfile/15114/2 "2004-06-12T15:22:47Z")

</div>

Hi Bojan, You must set the filename as a range of files (ex. : “C:\TEST\_._”). Then you can proceed like this: [i, str1] = WinApi::findFirstFile(fileName); while (WinApi::findNextFile(i)) { str1 = WinApi::findNextFile(i); } However, it only gets a part of them, not all (I don’t undestand why). Regards, CD

---

<div class="post-metadata">

**Author:** ![john.fo](https://avatars.discourse-cdn.com/v4/letter/j/f07891/32.png) [@john.fo](https://www.dynamicsuser.net/u/john.fo)\
**Post date:** [June 24, 2004, 1:13pm UTC](https://www.dynamicsuser.net/t/winapi-findnextfile/15114/3 "2004-06-24T13:13:03Z")

</div>

Hi Bojan, I encountered the same problem, but I solved it by making a wildcard for the find first file, then making a “dummy” FindNextFiles (to get past the . and … which are the first two files in a directory see example below: files = WinApi::findFirstFile(filepath + ‘\*’); WinApi::findNextFile(conpeek(files,1)); filname = WinApi::findNextFile(conpeek(files,1)); while (filnavn != ‘’) { IOFile = new AsciiIo(filepath + ‘\’ + filname,‘R’); . . }

---

<div class="post-metadata">

**Author:** ![bojan.jovicic](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@bojan.jovicic](https://www.dynamicsuser.net/u/bojan.jovicic)\
**Post date:** [July 5, 2004, 7:00am UTC](https://www.dynamicsuser.net/t/winapi-findnextfile/15114/4 "2004-07-05T07:00:43Z")

</div>

10x John.fo & Mugur I have found the use of winapi in some other language on internet, but didn’t know that the forum has moved. 10x again [:)]
