|
-
Dec 7th, 2001, 04:25 PM
#1
Thread Starter
Frenzied Member
FileExists
This works in every situation. Its the best way to do it!
VB Code:
Private Function FileExists(FullFileName As String) As Boolean
On Error GoTo CheckError
If FileLen(FullFileName) = 0 Then
FileExists = False
Else
FileExists = True
End If
Exit Function
CheckError:
FileExists = False
End Function
-
Dec 7th, 2001, 04:28 PM
#2
what is wrong with using :
if dir(fullfilename) > "" then
filename exists
else
filename dont exist
endif
-
Dec 7th, 2001, 04:28 PM
#3
Member
Not exactly, download this file and run your test on it.
Edit: Well the board rejected it because it was 0 bytes, and your function will fail with it.
-
Dec 7th, 2001, 04:31 PM
#4
Thread Starter
Frenzied Member
Originally posted by filburt1
Not exactly, download this file and run your test on it.
Edit: Well the board rejected it because it was 0 bytes, and your function will fail with it.
How often are you going to want to check a 0 byte file though.
Thats my Q.
Last edited by Evan; Dec 7th, 2001 at 05:59 PM.
-
Dec 7th, 2001, 04:32 PM
#5
How about:
VB Code:
Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
Public Function FileExists(ByVal Path As String) As Boolean
FileExists = PathFileExists(Path)
End Function
'Or you could just use it like this:
dim TorF as Boolean
TorF=PathFileExists(Path)
-
Dec 7th, 2001, 04:33 PM
#6
FileExists means the file is in the directory, not how big it is.
I create tmp files that are empty all the time, but I check for their EXISTENCE.
Different thing, I believe.
-
Dec 7th, 2001, 04:37 PM
#7
Thread Starter
Frenzied Member
Originally posted by jim mcnamara
FileExists means the file is in the directory, not how big it is.
I create tmp files that are empty all the time, but I check for their EXISTENCE.
Different thing, I believe.
I could see that. I think I like the API version the best so far.
-
Dec 7th, 2001, 05:21 PM
#8
Actually here is a module that just has the most common FSO functions that I use only done through APIs so I don't have to distribute it.
-
Dec 7th, 2001, 05:37 PM
#9
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|