GetFileSize

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ketchup

    GetFileSize

    Hi everyone,

    I am working in VB.NET 1.0. I am trying to use the Windows API function GetFileSize. It's a bit of a long story why I must use this function, rather then the built-in .NET System.IO.FileI nfo.Length property. I have the function declared as follows:

    ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~
    <DllImport("ker nel32", EntryPoint:="Ge tFileSize", SetLastError:=T rue, _
    ExactSpelling:= True, CallingConventi on:=CallingConv ention.StdCall) _
    Shared Function GetFileSize(ByV al hFile As IntPtr, ByRef lpFileSizeHigh As Integer) As Integer

    End Function

    ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~
    I am calling the function as follows:

    ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~
    Dim loworder As Integer
    Dim highorder As Integer
    loworder = GetFileSize(hfi le, highorder)

    ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~
    The function works as long as the file size is under 6 GB. When the file size is over 6 GB, highorder is still 1. For example for a 7.56 GB file, highorder is still 1, and lowerder -450 MB or so. In this example, highorder wants to be 2, but I am just not getting that from the function. I must be missing something obvious. Am using the wrong datatypes?

    Thanks!



  • Armin Zingler

    #2
    Re: GetFileSize

    "Ketchup" <ketchup@ketchu p.comschrieb
    <DllImport("ker nel32", EntryPoint:="Ge tFileSize",
    SetLastError:=T rue, _
    ExactSpelling:= True, CallingConventi on:=CallingConv ention.StdCall) >
    _
    Shared Function GetFileSize(ByV al hFile As IntPtr, ByRef
    lpFileSizeHigh As Integer) As Integer
    >
    End Function

    Did you read how to interpret the returned values?




    Armin

    Comment

    • Ketchup

      #3
      Re: GetFileSize

      Actually, NVM. I ended up using GetFileSizeEx instead. It's much easier to just use that function.
      "Ketchup" <ketchup@ketchu p.comwrote in message news:eSkzNo4OJH A.1268@TK2MSFTN GP06.phx.gbl...
      Hi everyone,

      I am working in VB.NET 1.0. I am trying to use the Windows API function GetFileSize. It's a bit of a long story why I must use this function, rather then the built-in .NET System.IO.FileI nfo.Length property. I have the function declared as follows:

      ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~
      <DllImport("ker nel32", EntryPoint:="Ge tFileSize", SetLastError:=T rue, _
      ExactSpelling:= True, CallingConventi on:=CallingConv ention.StdCall) _
      Shared Function GetFileSize(ByV al hFile As IntPtr, ByRef lpFileSizeHigh As Integer) As Integer

      End Function

      ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~
      I am calling the function as follows:

      ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~
      Dim loworder As Integer
      Dim highorder As Integer
      loworder = GetFileSize(hfi le, highorder)

      ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~
      The function works as long as the file size is under 6 GB. When the file size is over 6 GB, highorder is still 1. For example for a 7.56 GB file, highorder is still 1, and lowerder -450 MB or so. In this example, highorder wants to be 2, but I am just not getting that from the function. I must be missing something obvious. Am using the wrong datatypes?

      Thanks!



      Comment

      Working...