• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 921
  • Last Modified:

ASP.NET file contentlength

I'm passing in a variable to a sub as a string.

Private Sub UpdateDb(ByVal filename As String)

I need to get the file length. (size)

When I was passing it in as a collection I could get the file lengthwith

Dim _size = filename.contentlength

I still need the file size...some help?
0
Larry Brister
Asked:
Larry Brister
  • 3
  • 3
2 Solutions
 
David H.H.LeeCommented:
Dear lrbrister,
Try this:
Dim fileInfo As New System.IO.FileInfo(filename)
Dim _size as string
_size=fileInfo.Length 'result returned in bytes.

       
0
 
Raju SrivatsavayeSoftware EngineerCommented:
Is it possible to pass the file length as the parameter too!!
0
 
Larry Bristersr. DeveloperAuthor Commented:
x_com:
  That gives me the character length.  I need the file size
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Raju SrivatsavayeSoftware EngineerCommented:
to get the file size in kb do this..

filename.length/1024
0
 
Larry Bristersr. DeveloperAuthor Commented:
srivatsavaye:
filename.length gives me the characterlength of the filename.
0
 
Raju SrivatsavayeSoftware EngineerCommented:
sorry it should be file.contentlength/1024
0
 
Larry Bristersr. DeveloperAuthor Commented:
That's it guys.  Thanks and splitting points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now