The method of obtaining file size in VB _vb

Source: Internet
Author: User

This article illustrates the method of obtaining file size by VB. Share to everyone for your reference. The implementation method is as follows:

 <% ' Copyright (c) 2009, reusablecode.blogspot.com; some rights. ' This work is licensed under the Creative Commons attribution.
  To view ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California ' 94305, USA.
  ' Retrieve the file size of a given file.
    function GetFileSize (somefile) Dim fs Dim File Set fs = Server.CreateObject ("Scripting.FileSystemObject") Set file = fs.
  GetFile (Server.MapPath (somefile)) GetFileSize = Formatfilesize (file.size) Set file = Nothing Set fs = Nothing
  End Function ' Format a file size in the most practical units. ' Input:size in bytes function formatfilesize (size) Dim units Dim Factor = Array ("B", "KB", "MB", "GB "," TB "," PB "," EB "," ZB "," YB ") factor = log (size) \ 7 Formatfilesize = Round (Size/(1024 ^ factor), 2) & UN Its (factor) End Function%> 

I hope this article will help you with your VB programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.