473,503 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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!

Oct 31 '08 #1
2 4288
"Ketchup" <ke*****@ketchup.comschrieb
<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

Did you read how to interpret the returned values?
http://msdn.microsoft.com/en-us/libr...55(VS.85).aspx

Armin
Oct 31 '08 #2
Actually, NVM. I ended up using GetFileSizeEx instead. It's much easier to just use that function.
"Ketchup" <ke*****@ketchup.comwrote in message news:eS**************@TK2MSFTNGP06.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.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!

Oct 31 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2217
by: Scott Baxter | last post by:
Hello, I got the following scripts to upload files to my directories I call insert.htm Browse for a file, then click 'submit' It works for small files, and for a small .mdb (access file)
17
25384
by: Lauren Wilson | last post by:
Hi folks, Can someone point me to some resources on how to control FTP sessions from and Access application with VBA? Many thanks for all help. --LW.
3
4416
by: Marcia Hon | last post by:
Hi, I am trying to use the select() socket programming command to select between stdin and a connection. Currently, I have a listening stream and stdin that I insert into the fd_set. The problem...
2
9112
FTP
by: Tony | last post by:
How do you put/get a file via ftp from a C# Windows App? I can't seem to find any classes that can do this. Tahnk You,
12
2178
by: John Baker | last post by:
Hi: I have read a number of threads on the issue of compressing (compacting) Access data bases programmatically, and have been left confused. We are using Access 2000, and I need code that will...
9
8288
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
0
1472
by: Holly | last post by:
I copied this code that works to connect into Unix. I am looking for a way to get it to work with a secure Unix box. Anyone have any insights on how to do this? I am trying to build an sftp...
0
9766
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
0
789
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.