>Hi friends
>just wondering whats the fastest way to find if a file exist and if so open it.
>the reason ask we've some clients with more 100,000 docs which can be accessed thru our app.
>at the moment find a file and opening a file taking noticeable time.
>btw we are using "file()" command at the moment
Finding if a file exists in a single directory of 100,000 files may be slow, because of the way the operating system works. This has nothing to do with Visual FoxPro: Try to open a DOS command window and give a command like:
dir MyFile.txt
(after selecting the correct directory with the CD command).
If this is too slow, there is a problem with the operating systme.
One thing that can help is to use NTFS as a file system - it seems this uses some sort of file indexing, which should make file access faster.
But in general, it is recommended NOT to have so many files in a single directory. Find a way to split it into separate directory, perhaps by date or by the first letter of the filename.
In Visual FoxPro, file() is known to be unreliable. Specifically, it will say that a file exists, even if it finds the file within the EXE or among the search path. Instead, use:
if adir(SomeArray, "myfile.txt") > 0
endif
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)