Bueno esto es sólo una función sencilla de determinar el tamaño de archivo de un archivo.
Option Explicit
'---------------------------------------------------------------------------------------
' Module : mFileSize
' DateTime : 25/12/09 02:19
' Author : Mi4night
' Mail : mi4night@hotmail.com
' Usage : At your own risk.
' Purpose : Get the size of a file
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
'---------------------------------------------------------------------------------------
Private Declare Function GetCompressedFileSize _
Lib "kernel32" _
Alias "GetCompressedFileSizeA" (ByVal lpFileName As String, _
lpFileSizeHigh As Long) As Long
Public Function GetFileSize(FilePath As String) As String
'Variable Declaration
Dim FSize As Double
'Verify that the FilePath is given
If Len(FilePath) <> 0 Then
'Getting FileSize in bit
FSize = GetCompressedFileSize(FilePath, ByVal 0&)
If FSize < "1024" Then
GetFileSize = FSize & " Bytes"
ElseIf FSize >= "1024" And FSize < "1048576" Then
GetFileSize = Round(FSize / 1024, 2) & " KB"
ElseIf FSize >= "1048576" Then
GetFileSize = Round(FSize / 1048576, 2) & " MB"
End If
Else
Exit Function
End If
End Function
[Valor Double] < [Texto Numerico]
Es = a mas de tiempo.
lo recomendable seria dejar los números sin comillas...
Yo uso personalmente: GetFileSize().. para esto en vb6.
y en lugar de usar Round() usa FormatNumber() y asi no concatenas bueno seria una alternativa...!¡.
Sangriento Infierno Lunar!¡.
Hola, tengo una duda muy tonta:
xk utilizar una funcion si con FileLen(Path) obtenemos (yo creo) el mismo resultado?? :huh:
No estoy criticando la funcion ni mucho menos, solo es una duda...
Disculpen mi ignorancia... :laugh:
Gracias! ;D
BlackZeroX yeah you are right about the qoutes i use, it's a bad habbit of mine.
@*PsYkE1* Yeah you get the same when using filelen then you need then only to do the calculation as i did.:P But i love API
Ok, thanks for the answer men, good job! ;D