Results 1 to 4 of 4

Thread: [RESOLVED] filesize function

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Resolved [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

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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!

  3. #3
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: filesize function

    It clearly states Length is not declared. What is + Length?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    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
  •  



Click Here to Expand Forum to Full Width