?
Solved

Getting the filesize (Length)

Posted on 2011-03-10
3
Medium Priority
?
419 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 2000 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 46

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

743 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