John Spencer <(E-Mail Removed)> wrote:
> Is the file stored on drive somewhere on the network? You can check for
> it's existence using the DIR function. That is pretty quick
Just buttin' in to say the commonly accepted practice is to use Attrib() rather than
Dir() for simple file existence checks, because using Dir releases any existing open
search handle that Dir may have created elsewhere in the application. (Kinda like
using FreeFile rather than hardcoding a specific file handle.) Ex:
Public Function FileExists(ByVal FileName As String) As Boolean
Dim nAttr As Long
' Grab this files attributes, and make sure it isn't a folder.
' This test includes cases where file doesn't exist at all.
On Error GoTo NoFile
nAttr = GetAttr(FileName)
If (nAttr And vbDirectory) <> vbDirectory Then
FileExists = True
End If
NoFile:
End Function
Public Function FolderExists(ByVal PathName As String) As Boolean
Dim nAttr As Long
' Grab the attributes, test valid values for folder bit.
On Error GoTo NoFolder
nAttr = GetAttr(PathName)
If (nAttr And vbDirectory) = vbDirectory Then
FolderExists = True
End If
NoFolder:
End Function
Carry on...
--
..NET: It's About Trust!
http://vfred.mvps.org