November 4th, 2003, 04:25 AM
File Handling problem
I have written ftp client using VB.
In this i used Get, Put and Seek statements for the local file handling when uploading and downloading. But these statements are not supporting the files larger than 2G.
I decided to use CreateFile, ReadFile and WriteFile apis. But in case of these api how to seek the file pointer to the perticular location in the file ?
Please help me
November 4th, 2003, 08:52 AM
SetFilePointer , SetFilePointerEx APIs move the file pointer of an open file.
November 4th, 2003, 07:47 PM
but will the setfileptr move the file positon more than 2GB ? because api has the long parameters...
i want to seek the file more than 2GB. is it ok with setfileptr?
November 5th, 2003, 08:29 AM
long (4 bytes=32bits) can not store more than 2GB number..
but note that SetFilePointer :
as you see it takes the second argument as the 32 Low-order 32 bits (unsigned) and the third argument is a Pointer to the high-order 32 of the 64-bit (the total is 64 bits=8bytes which can store much more than 2GB)...
HANDLE hFile, // handle to file
LONG lDistanceToMove, // bytes to move pointer
PLONG lpDistanceToMoveHigh, // bytes to move pointer
DWORD dwMoveMethod // starting point
So you can exceed 2GB by using this function
See MSDN for details
hope this can help
November 6th, 2003, 02:53 AM
Ya, I got it . Thanks for the INformation.
I converted the 64 bit value into two 32-bit values and passed to the setfilepointer.
It works fine.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!