Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADIR() and Filename Case-sensitivity

Status
Not open for further replies.

JRB-Bldr

Programmer
May 17, 2001
3,281
US
I have been using ADIR() for a while now to get a list of filenames within a directory.

Now I have to use those filenames, send them to a Linux system and have a user do things with them there.

The problem is that in VFP7 ADIR() delivers the list of filenames in all CAPS and the Linux system is case-sensitive. Therefore when the capitalization of the filename does not match, the application screen within the Linux system tells the user that the file does not exist.

I have no control over the Linux system's vendor-supplied application so I cannot address the problem from that side. Therefore I need to prepare a list from the VFP7 side which shows the accurate filename capitalization.

Any suggestions?

Thanks,
JRB-Bldr
 

Fool it

Code:
public ARRAY MYPRESERVEDCASE[1]
path = "C:\"
ofs=create('scripting.filesystemobject')
n = ADIR(arr,path+"*.*")
DIMENSION MYPRESERVEDCASE[n]
FOR ii = 1 TO n
    MYPRESERVEDCASE[ii] = ofs.getfile(path+arr[ii,1]).name
NEXT

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Code:
?ShowFolderList(SYS(5)+SYS(2003))

PROCEDURE ShowFolderList(cDir)
   oFS = CREATEOBJECT("Scripting.FileSystemObject")
   cFolder = oFS.getfolder(cDir)
   cFileCollection = cFolder.FILES
  
  FOR EACH cFile IN cFileCollection
   ?cFile.NAME
  NEXT
ENDPROC

Brian
 
I believe that the ADIR nFlag, the last (optional) parameter, also perserves case if it is set to 1...

Code:
FOR i = 1 TO ADIR(aa,ADDBS(SYS(5)+SYS(2003))+"*.*","",1)
  ?aa[i,1]
ENDFOR
 

From the Help file, re 3rd parameter to ADIR():

nFlag
Specifies whether the display provides DOS naming or actual case sensitivity.
nFlag Description
0 (Default) Display represents the full file name in uppercase
1 Display represents original Case in names
2 Display follows DOS 8+3 naming convention

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
FoxPro's problem is perserving case with a file copy which is where File Scripting come in handy...

Code:
cString ="Test"
STRTOFILE(cString,"Case.Test",0)

COPY FILE Test.Test TO CaseLost.Test

oFS = CREATEOBJECT("Scripting.FileSystemObject")
oFS.CopyFile ("Test.Test", "CasePerserved.Test")

FOR i = 1 TO ADIR(aa,ADDBS(SYS(5)+SYS(2003))+"*.test","",1)
  ?aa[i,1]
ENDFOR
 
Hi JRB-Bldr,

The 3rd ADIR() parameter is not available in VFP7. So you need to make use of Scripting.FileSystemObject or of some Win API call like GetFullPathName, if the local admin swiched off Windows Scripting Host.

Bye, Olaf.
 
Hi Mike,

sorry, meant the 4th, the nFlags. But it's also there in VFP7. Set nFlags=1 and you get capitalisation as on disk, like baltman already said.

Bye, Olaf.
 
Thank you for all the replies.

Since before this time I have not had need to get anything more out of the the ADIR() command I guess that I just mistakenly assumed that I needed to look at a different approach.

But, having tried your suggestions of setting my VFP7 ADIR()'s 3rd nFlags parameter things are working well now.

Thanks to everyone.
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top