Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Size of a File 1

Status
Not open for further replies.

TailWagger

Technical User
Nov 1, 2000
18
US
I need to retrieve the size of a file. I have the file name but need some help in the coding to obtain the directory information. Thanks much!

 
Pulled this off the net

' Name: Determine the size of a file
' Description:You can get the size of a file two ways.
' By: Gord's VB Code Snippets
'
'Inputs:None
'Returns:None
'Assumes:None
'Side Effects:None
'
'Code provided by Planet Source Code(tm) 'as is', without
' warranties as to performance, fitness, merchantability,
' and any other warranty (whether expressed or implied).
' If you have the file open you can use the LOF function.
Dim nFileNum As Integer
Dim lFileSize As Long
' 'Get a new file number
nFileNum = FreeFile
' 'Open the file
Open "C:\SOMEFILE.TXT" For Input As nFileNum
' 'Get the Length
lFileSize = LOF(nFileNum)
' 'Close the file
Close nFileNum
' If you don't have the file open you can use the
' FileLen function.
Dim lFileSize As Long
lFileSize = FileLen("C:\SOMEFILE.TXT")



HTH
PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top