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
Solved

Getting the filesize (Length)

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Passing Credentials into a command line 13 38
Save ms data to server side. 19 55
Need syntax help building hyperlink 2 20
asp.net mvc , views, hidden values ? 2 16
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…

791 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