The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Bug? FindFirstFile/FindNextFile

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
hajo_old Posted - 03/02/2004 : 03:19:02 AM
Hello, all

Yust found some curious behaviour of the FindFirstFile/FindNextFile functions.

Searching a directory (with the example "dir" function in the help) with > dir C:\TestDir\*.xls < gets me 30 files. Till this point everything is all right, but renaming one to "*.xls_" also gives me all the 30 files - I would expect to get 29 files back; renaming one to "*.xl" works all right - 29 hits!!

I guess the FindFile functions search of occurances in the filename not for similatities?!

Thanks
Hajo

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1 is now hajo

Edited by - hajo on 03/02/2004 03:21:46 AM
3   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 03/02/2004 : 08:16:29 AM
FindFirstFile/FineNextFile are Windows API functions. OC just directly call these. I think the rule of file extension must be obsereved with FindFirstFile etc as they are coming from the DOS days. When you rename a file as a.xls_, it is no longer recorgnized as a valid file extension as it has 4 characters, but rather a file name with a dot in the middle, without file extension.

CP


hajo_old Posted - 03/02/2004 : 07:04:03 AM
Hello, Iris

The folder to run the dir command on is filled by n files with the extention *.xls.

renaming 2 of them to *.xls_ or *.xl produced the described problem.

the following code shows the functions I used.
the function call in the sript window was: > dir_ "X:\MyPath\*.xls" <

 StringArray dir(string strFile)
{
WIN32_FIND_DATAA find;
HANDLE hFile;
StringArray adC;
int anzMax;

//out_str(strFile);
//UINT size = adC.GetSize();
//out_int("Groesse Vektor: %i\n",size);

// 1. Durchlauf zum zaehlen der gefundenen Dateien
int nCount = 0;
if((hFile=FindFirstFile(strFile,&find)) != INVALID_HANDLE_VALUE)
{
nCount++;

while(FindNextFile(hFile,&find))
{
nCount++;
}
printf("%d files found\n",nCount);
FindClose(hFile); // must close the hadle
anzMax = nCount;

// 2. Durchlauf zum fuellen des Uebergabevektors
nCount = 0;
adC.SetSize(anzMax);
if((hFile=FindFirstFile(strFile,&find)) != INVALID_HANDLE_VALUE)
{
adC[nCount] = find.cFileName;
nCount++;

while(FindNextFile(hFile,&find))
{
adC[nCount] = find.cFileName;
nCount++;
}
FindClose(hFile); // must close the hadle
}
}
else
{
printf("%s: file(s) not found\n",strFile);
}
adC.Sort();
return adC;
}


void dir_(string strFile)
{
StringArray sa;
sa = dir(strFile);
sa.Sort();
for(int ii=0; ii<sa.GetSize(); ii++)
{
printf("%s\n",GetFileName(sa[ii]));
}
}


Hajo

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1 is now hajo

Edited by - hajo on 03/02/2004 07:38:25 AM
Iris_Bai Posted - 03/02/2004 : 06:29:54 AM
Hi Hajo,

I cannot reproduce the problem. Run the sample code in v7.5 776, use *.xl and *xls_ cannot find any file. But *.xls works fine.

Iris

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000