How do I determine the size of any file in a certain directory? (In VB 6.0)
Printable View
How do I determine the size of any file in a certain directory? (In VB 6.0)
the filelen(filename) function will give up the size of the file
filedatetime will give the date and time last modified.
'1 filelistbox
'1 command button
'select a file from file list box, then click on command button
Option Explicit
Private Sub Command1_Click()
Dim lngFileSize As Long
lngFileSize = FileLen(File1.FileName)
MsgBox "File Size: " & Format(lngFileSize, "###,###,### bytes")
End Sub
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
If it's an open file, you can use the LOF() function
open "test.txt" for binary as #1
msgbox LOF(1)
close #1
Dim filesys,f As Object
Set filesys = CreateObject("Scripting.FileSystemObject")
Set f = filesys.GetFolder(folderpath)
Msgbox f.Size
Iouri Boutchkine
[email protected]