GetFileSize

K

Ketchup

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.FileInfo.Length property. I have the function declared as follows:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<DllImport("kernel32", EntryPoint:="GetFileSize", SetLastError:=True, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Shared Function GetFileSize(ByVal 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(hfile, 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!
 
K

Ketchup

Actually, NVM. I ended up using GetFileSizeEx instead. It's much easier to just use that function.
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.FileInfo.Length property. I have the function declared as follows:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<DllImport("kernel32", EntryPoint:="GetFileSize", SetLastError:=True, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Shared Function GetFileSize(ByVal 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(hfile, 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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top