on 8/31/2011, Ludo supposed :
On 31 aug, 15:31, GS wrote:
Optional usage...
* Sub DoStuff()
* * If PathExists("\\Server\Share") Then
* * * '//do stuff
* * * Else
* * * * Dim sMsg As String
* * * * sMsg = "The network drive is not available." & vbCrLf
* * * * sMsg = sMsg & "Please try again later!"
* * * * MsgBox sMsg, vbExclamation
* * End If 'PathExists("\\Server\Share")
* End Sub
..which only executes your code if the path exists AND is available.
--
Garry
Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Thanks Gary!
Just needed to change PathExists = '(Dir$(sPath & "\nul") < "") into
PathExists = (Dir$(sPath & "\*.log") < "") to get it working.
Otherwise it returned always FALSE.
Keep up the good work!
Regards,
Ludo
That means you're testing for files, NOT a path. In this case I suggest
you use the following function instead, leaving the PathExists function
unchanged.
' Checks if a file exists in the specified folder
' Arguments: fileName The fullname of the file
' Returns: TRUE if the file exists
Function bFileExists(Filename As String) As Boolean
On Error Resume Next
bFileExists = (Dir$(Filename) < "")
' bFileExists = (FileLen(Filename) < 0) '//optional method
End Function
--
Garry
Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc