Solved

Getting the filesize (Length)

Posted on 2011-03-10
3
414 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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