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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Bug? FindFirstFile/FindNextFile
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hajo_old

Germany
141 Posts

Posted - 03/02/2004 :  03:19:02 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Iris_Bai

China
Posts

Posted - 03/02/2004 :  06:29:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

hajo_old

Germany
141 Posts

Posted - 03/02/2004 :  07:04:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 03/02/2004 :  08:16:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000