Solved

Getting the filesize (Length)

Posted on 2011-03-10
3
418 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
[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
3 Comments
 

Author Comment

by:TheWebGuy38
ID: 35105216
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
ID: 35111481
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
ID: 35112994
You need to cast it as a string:

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

Open in new window

0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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