elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  [VB6]mFileSize
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [VB6]mFileSize  (Leído 1,919 veces)
Mi4night

Desconectado Desconectado

Mensajes: 12


The Art of Mind Fucking...


Ver Perfil
[VB6]mFileSize
« en: 2 Mayo 2010, 02:54 am »

Bueno esto es sólo una función sencilla de determinar el tamaño de archivo de un archivo.

Código:
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



En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: [VB6]mFileSize
« Respuesta #1 en: 2 Mayo 2010, 08:13 am »


[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!¡.


En línea

The Dark Shadow is my passion.
Psyke1
Wiki

Desconectado Desconectado

Mensajes: 1.089



Ver Perfil WWW
Re: [VB6]mFileSize
« Respuesta #2 en: 2 Mayo 2010, 13:36 pm »

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
En línea

Mi4night

Desconectado Desconectado

Mensajes: 12


The Art of Mind Fucking...


Ver Perfil
Re: [VB6]mFileSize
« Respuesta #3 en: 2 Mayo 2010, 15:55 pm »

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
En línea

Psyke1
Wiki

Desconectado Desconectado

Mensajes: 1.089



Ver Perfil WWW
Re: [VB6]mFileSize
« Respuesta #4 en: 2 Mayo 2010, 16:57 pm »

Ok, thanks for the answer men, good job! ;D
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines