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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NUL doesn't work in FILE() in Win2000 2

Status
Not open for further replies.

Brak

Programmer
Jul 11, 2001
158
US
I have a program that checks for the existence of a directory using the FILE() function using NUL.
EX:
? FILE("C:\TEMP\NUL")

In Win9x it works as it should giving .T. if it does exist.
In Win2000 it doesn't work and gives .F. no matter what.

Here's a link from MS which confirms this usage:

Its curious that the MS page, which has a Last Review date of December 1, 2003, says nothing about this.

Does anyone have any info on this problem.
 
Hi Brak:

I think it is because Win 9x stores files in Fat32 Standard and Win 2000/XP uses NTFS. You can still install XP in Fat32. I am not sure if this the problem. Here is a work around.

if adir(t_array,"c:\Temp","d") > 0
? "Directory Exist"
else
? "Directory Does not Exist"
endif


Nasib
 
You may want to go back a re-read that article.
The example given in that article states
FILE() attempts to locate a file or directory on disk and returns .T. or .F. based on the results of the search. Specify the filename to search for as a character string argument. To test for the existence of a directory, specify NUL as the filename. For example:

David W. Grewe Dave
 

David W. Grewe,
Sorry, but you may want to go back and re-read Brak's question.

He (she?) mentions that the article confirms the usage of NUL as the file name.

The OP's problem is that in Win9x this usage works as described, but it seems to be not supported in Win200 - and the OP is surprized the the article revized in 2003 - well after Win2000 was released - doesn't mention anything about that usage being not supported any longer.

Brak,
I think, Nasib is right, this may be due to the fact that Win2000 and later are using a different file system. This article relates to no later than v.3.0, and, say, in VFP6 this usage is not described. I tried it in VFP6/WinXP, just in case it is still there undocumented, but it doesn't work.

I think you may want to go with work-around, to make your application more portable and reliable.
 
Thanks for the confirmation and alternative method!

I don't think it would be a NTFS issue, as all my drives except for my OS drive is FAT32, plus this function works with CD-ROM drives as well.

Thanks again!
 

Well, may be not NTFS. Still, since it seems not all Windows versions support it, you would be better off avoiding it.

Thanks for the star.
 
[ ]
In FP2x I use FCREATE() to test for the existance of a directory. If it exists, FCREATE() returns a valid file handle. If it does not exist, FCREATE() returns an invalid file handle (<0) and FERROR() contains error code '5' indicating a missing directory.

[blue]

zhandle = FCREATE(Path)

IF zhandle < 0 AND FERROR() = 5
* Fix missing directory here
ELSE
= FCLOSE(zhandle)
ENDIF

[/blue]

That should work in all versions of VFP and is independent of the underlying operating system.



mmerlinn


"Political correctness is the BADGE of a COWARD!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top