>If I allow the user to select a file using GETFILE(), how can I
>validate that the file ther user selected really IS the correct
>type of file?
>
>For example, if I use:
>
>
>cFileName = GETFILE("doc")
>>
>
>how can I be sure that the user selected a Word document?
I don't know that you can.
Windows associates certain file types by file extension - which means you can give an Excel file a .DOC extension and Windows will attempt to open it with Word (e.g.). That may or may not be successful.
The best you may be able to do is confirm that the file they selected has the extension you gave to GETFILE(), e.g.lcExt = "doc"
lcFileName = GETFILE(lcExt)
IF !UPPER(JUSTEXT(lcFileName))==UPPER(lcExt)
ENDIF
note: JUSTEXT() is in Foxtools.fll if you're not using VFP 6.0 or later.
You could also use the FileSystemObject and get the file Type and check that, e.g.oFSO = CREATEOBJECT("Scripting.FileSystemObject")
oFile = oFSO.GetFile(GETFILE("doc"))
IF oFile.Type # "Microsoft Word Document"
ENDIF
Insanity: Doing the same thing over and over and expecting different results.