Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB.Net Getting file size in MBs/KB's

Posted on 2012-12-26
2
Medium Priority
?
3,666 Views
Last Modified: 2012-12-26
Hi Experts.  
Can some please explain why I keep getting the answer 13 when the actual file size is 1.3G and how I would get MB's and KB's

Dim filename As String
filename = ("C:\backup.pst")
MsgBox(filename.Length)

I've tried converting to integer and long but then I just get 0

Thanks
0
Comment
Question by:PNRT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 38721552
Because you are asking for the length of a string. "C:\backup.pst" is 13 characters in length. To get file size do:

Dim info As New System.IO.FileInfo(@"C:\backup.pst")
MsgBox(info.Length)

Open in new window

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38721564
P.S.

The Length property will give you the count of bytes for the file. To convert to human quantities you will have to do a bit of math:

info.Length / 1024  ' kilobytes
info.Length / 1048576 ' megabytes
info.Length / 1073741824 ' gigabytes

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question