I am coding in Borland C++Builder 6. In several of my applications I am using the following function to locate files on our network:
String sRootDir="N:\\";
String sClmNbr="748000";
TSearchRec fnd1;
if (FindFirst(sRootDir+sClmNbr+"*.PDF",faAnyFile,fnd1)==0)
{
lbClmCpy->Lines->Add(fnd1.Name);
while (FindNext(fnd1)==0)
{lbClmCpy->Lines->Add(fnd1.Name);}
FindClose(fnd1);
}
This is a watered-down version of the function, but you can see what I am trying to accomplish. I attempted to search for any file on N:
with a mask of 748000*.*
.
However, the function returns files that do not match the mask. After doing some digging, I discovered that it has to do with the 8.3 short names of the files. For whatever reason, the short names of the files are completely wrong. For example, 748123_20161110.pdf
should look something like 748123~1.pdf
, instead it shows 748AE4~1.PDF
. I know a work-around (by checking the 'Name' value on the file found, which would give me the full name, and then check the full name). However, this is crazy.
I have a few questions here:
Why would the short names be formatted incorrectly?
Is there a way to tell
FindFirst()
/FindNext()
to search for only long file names? If not, does anyone have an alternate function that could be used?There is a DOS command to disable short names completely. Are there any dangers when doing this? Also, if I disable this option on our network drive, will that suffice? All of the file operations take place from end-user pc's (do I have to disable short names on the individual PC's?