Solved

Getting the filesize (Length)

Posted on 2011-03-10
3
413 Views
Last Modified: 2012-08-14
Ok, someones going to laugh at me. this is a simple one for most probably :)

all I want to do is get the file size. somethings wrong with my syntax and it's having a problem with the integer

here is the code

having a problem right here

New System.IO.FileInfo(FilePath)

"value of type system.io.fileinfo cannot be converted to type integer



 
Dim GetVideo = DAL.GetVideoByID(ID)

        Dim FilePath = Server.MapPath(GetVideo)
        'Get File Size
        Dim fileSize As Integer = CType(New System.IO.FileInfo(FilePath), Integer).Length

        Response.Write("fileSize: " & fileSize)

Open in new window

0
Comment
Question by:TheWebGuy38
3 Comments
 

Author Comment

by:TheWebGuy38
Comment Utility
Oh wait, never mind. figured it out

 Dim fileSize As Integer = New System.IO.FileInfo(FilePath).Length

:)
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
Comment Utility
Length is a Long, and if you have Option Strict On, you will get an error.  You would need to use this:

Dim fileSize As Long = New FileInfo(filePath).Length

Open in new window

0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
You need to cast it as a string:

Response.Write("fileSize: " & fileSize.ToString())

Open in new window

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now