For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > April 2006 > Determining Size of a File









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Determining Size of a File
footyplayer

2006-04-03, 7:10 pm

Hello All,

I have a requirement to determine the size of a given file. My function
must obtain the file size, and return false if the file size is greater than
50mb. I have searched different sites, to no avail. Any help is greatly
appreciated!

Best Regards,
Brad


Bob Butler

2006-04-03, 7:10 pm

"footyplayer" <anonymous@discussions.microsoft.com> wrote in message
news:Ou4iwczVGHA.1728@TK2MSFTNGP11.phx.gbl
> Hello All,
>
> I have a requirement to determine the size of a given file. My
> function must obtain the file size, and return false if the file size
> is greater than 50mb. I have searched different sites, to no avail.
> Any help is greatly appreciated!


Read the help for the FileLen and LOF functions

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

Rick Rothstein

2006-04-03, 7:10 pm

> I have a requirement to determine the size of a given file. My function
> must obtain the file size, and return false if the file size is greater
> than 50mb. I have searched different sites, to no avail. Any help is
> greatly appreciated!


You should be able to use VB's built-in FileLen function for that...

Function IsFileSmall(PathAndFileName As String) As Boolean
IsFileSmall = Not (FileLen(PathAndFileName) > 50000000)
End Function

The FileLen function returns the number of bytes in a file, so I used
50000000 as your indicated 50 MB limit. If you want to use a different
definition of MB, then calculate how many bytes that would be and use that
in place of my 50000000 value in the function.

Rick


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com