Consider this example VBScript fragment:
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("D:\Folder\File*.ext") Then ' Finds nothing!
fs.CopyFile "D:\Folder\File*.ext", "D:\OtherFolder\"
fs.Deletefile "D:\Folder\File*.ext"
End If
The FileExists
method turns out not to support wildcards (*
and ?
). Not does FolderExists
. I expected wildards to just work because they work fine for all similar methods in the FileSystemObject
: CopyFile
, CopyFolder
, MoveFile
, MoveFolder
, DeleteFile
, DeleteFolder
and the Get*
filename handling methods like GetAbsolutePathName
.
Of course there are ways to work around this, like GetFolder
and iterating over its files. But FileExists
would have been much more readable, convenient, natural and consistent.
The fs.FileExists
inconsistency feels like an API design problem. What could be the reason? Is there some idea behind it?