intelliproject logo

Location: Desktop development - Visual Basic . NET    License: The Intelliproject Open License (IPOL)

Find the size of a file in VB.NET

Posted by Manu Abraham

Describe how to find the size of a file using VB.NET

Skill: Beginner

Posted: 27/11/2008

Views: 2305

Rating: 0.00 /5

Popularity: 0.00

Sign Up to vote for this article

Introduction

In this article , I am going to describe the steps to find the size of a file using VB.NET.

Using the code

We need to find the size of a file. We can get the information about the file using the 'FileInfo'  class in VB.NET. The 'FileInfo'  class belongs to the 'System.IO' Namespace.

So we need to import the particular namespace using the following line in our script

Imports System.IO

We can make use of the 'FileInfo' to get the size of the file.

Dim MyFile As New FileInfo(MyFilePath)
Dim FileSize As Long = MyFile.Length
Return FileSize

Where MyFile is the object of the class 'FileInfo' . The 'Length' property of the 'FileInfo'  class will give the size of the file.

In the following code , we just need to input the full path to the file, whose size is to find out.

Conclusion

Please forward your queries and suggestions to:

manu@phppals.net
manu@manuabraham.info

http://manuabraham.info

License

This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)

About the author

Manu Abraham

Manu Abraham having an experience of more than 3 years in PHP-MySQL web development.

Location: India
Ocupation: web Developer
Home page: http://manuabraham.info

Sign up to post message on the article message board!