ValidateJetFileName Method

This method performs file existence verifications.  It checks to see if a file specified by name exists, and returns a TRUE/FALSE value depending on the value passed as the second argument.   

IDL Definition

HRESULT ValidateJetFileName(
[in] BSTR bstrFileName, 
[in] BOOL fWantNew, 
[out, retval] BOOL *pfValid
);

Parameters

bstrFileName

the full or relative path to the file.  All relative names are from the c:\winnt\system32 directory. (e.g. "mydb.mdb" -> "c:\winnt\system32\mydb.mdb"

fWantNew

a flag specifying the intent of the validation check.  If fWantNew is TRUE (1), then the returned BOOL will indicate FALSE if any file already exists by that name.  If fWantNew is FALSE, then the returned BOOL will return TRUE if a file by that name exits, and FALSE otherwise. 

pfValid

on return, the address of a BOOL variable. (TRUE/FALSE)

Return Values

a standard HRESULT.

Remarks

This method does not check to see whether the file specified is an access database or not.  It simply checks to see if the file exists. 

The matrix of possible BOOL values "returned"  (i.e. the address of the BOOL contained in the third argument on return) is listed below.

fWantNew (second argument) File by that name already exists? Returned BOOL variable address contains
TRUE yes FALSE
TRUE no TRUE
FALSE yes TRUE
FALSE no FALSE

Example

Set ObjCreator = CreateObject("ObjCreator.ObjCreator.1")
Set DSConfig = ObjCreator.CreateObjAuth("MemAdmin.DSConfig.1")
fWantNew=TRUE
Filename="c:\databases\db1.mdb"
if DSConfig.ValidateJetFilename(Filename,fWantNew) Then
  DSConfig.CreateJetDB(…)
Else 
  WScript.Echo "Name conflict encountered. DB not created"
End If

© 1997-1998 Microsoft Corporation. All rights reserved.