|
-
Jan 11th, 2003, 04:15 AM
#1
Thread Starter
Junior Member
Detecting Empty Files
Hi,
I am having trouble detecting an empty file opened in Binary mode. I have tried the following function and it always returns false.
Code:
Public Function fnEmptyFile (ByVal strPath as String)
Dim FileHandle%
FileHandle% = FreeFile
Open strPath For Binary Access Read Write As #FileHandle%
If (EOF(FileHandle%) = True) then
fnEmptyFile = True
else
fnEmptyFile = False
End If
Close #FileHandle%
End Function
Does anyone have any suggestions as to how to detect an empty file?
Thanks
MechEngCoder
-
Jan 11th, 2003, 04:16 AM
#2
Thread Starter
Junior Member
Sorry forgot the As Boolean in the function header, typo
-
Jan 11th, 2003, 04:17 AM
#3
PowerPoster
there's got to be a method somewhere (FSO, maybe?) that gives you the file size, so you could just look for size=0
-
Jan 11th, 2003, 04:20 AM
#4
Thread Starter
Junior Member
Thanks, does anyone know the method could not see under FSO?
-
Jan 11th, 2003, 10:21 AM
#5
PowerPoster
in the same scripting library that contains the FSO there is a "file" object that has a "size" property
-
Jan 11th, 2003, 10:58 AM
#6
Frenzied Member
You can just use the Filelen function.
VB Code:
if Filelen(Filepathandname) = 0 then
'file is empty
endif
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Jan 11th, 2003, 02:37 PM
#7
After you open the file, you can use "LOF(#FileHandle%)"
-
Jan 12th, 2003, 03:53 AM
#8
Thread Starter
Junior Member
Thanks works a Treat
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
|