|
-
May 22nd, 2013, 05:11 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] filesize function
Code:
Public Function getFileSize(ByVal path As String) As String
Dim sizes() As String = New String() {"B", "KB", "MB", "GB"}
Dim len As Double = (New FileInfo(path) + Length)
Dim order As Integer = 0
While ((len >= 1024) _
AndAlso (order + (1 < sizes.Length)))
order = (order + 1)
len = (len / 1024)
End While
Return String.Format("{0:0.##} {1}", len, sizes(order))
End Function
Can anyone help, why do i get: Error 1 'Length' is not declared. It may be inaccessible due to its protection level. H:\X17-59183\PostInstall\PostInstall\SelectPrograms.vb 111 51 PostInstall
-
May 22nd, 2013, 05:26 PM
#2
Re: filesize function
Probably because it's not declared! Is this what you're trying to do?
Dim fLength = My.Computer.FileSystem.GetFileInfo(path).Length
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 22nd, 2013, 05:28 PM
#3
Re: filesize function
It clearly states Length is not declared. What is + Length?
-
May 22nd, 2013, 06:27 PM
#4
Thread Starter
Hyperactive Member
Re: filesize function
thanks dun, that fixed it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|