Solved

How to use SetFilePointer for more than 4 GB Files ?

Posted on 2003-11-04
2
666 Views
Last Modified: 2013-11-13
Hi,

I have written a FTP Client using winsock VB. and providing the resume option for upload and download.
When transfering more than 2GB or 4GB files, I am not able to seek the file pointer to the huge files.
can anybodya please provide me some example to set the file pointer to the more than 4GB?

thanking you
regards
p01
0
Comment
Question by:p01
2 Comments
 

Accepted Solution

by:
pampati earned 75 total points
ID: 9686009
You need to convert the 64 bit value into two 32-bit values and pass those to the setfilepointer api.

Here is the example to convert 64 bit value to 32-bit values

Public Type MungeCurr
        Value As Currency
      End Type

      Public Type Munge2Long
        LoValue As Long
        HiValue As Long
      End Type

      Public Function convert64to32(ByVal Value As String) As Currency
      Dim L As Long, Negative As Boolean
        Value = Trim$(Value)
        If Left$(Value, 1) = "-" Then
          Negative = True
          Value = Mid$(Value, 2)
        End If
        L = Len(Value)
        If L < 4 Then
          TextToCurr = CCur(IIf(Negative, "-0.", "0.") & _
                            Right$("0000" & Value, 4))
        Else
          TextToCurr = CCur(IIf(Negative, "-", "") & _
                            Left$(Value, L - 4) & "." & Right$(Value, 4))
        End If
      End Function

and  call the above function like this.

        Dim C1 As MungeCurr
        Dim L As Munge2Long
        ' Convert a 64-bit value to two 32-bit values.
        C1.Value = convert64to32("1234567890123456")
        LSet L = C1
        SetFilePointer hFile, L.LoValue, L.HiValue, FILE_BEGIN

Hope this helps

Praveen Pampati
0
 

Author Comment

by:p01
ID: 9686255
Thanks for the code.
It works fine.

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bit defender blocks good applications 2 56
Determine Range to Select 5 35
WPF issue with Trigger 2 69
Copy a row 12 53
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now