Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #1802 > unrolled thread

FTP incomplete file transfer

Started byCMc <cmccaul@ruddwisdom.com>
First post2011-08-09 08:54 -0700
Last post2011-09-01 01:25 -0700
Articles 11 — 6 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  FTP incomplete file transfer CMc <cmccaul@ruddwisdom.com> - 2011-08-09 08:54 -0700
    Re: FTP incomplete file transfer D.J.W. van Kooten <public@ic2remove.this.com> - 2011-08-09 18:45 +0200
    Re: FTP incomplete file transfer SteveMcNaughton <stevemcnaughton@auditron.com> - 2011-08-18 09:49 -0700
    Re: FTP incomplete file transfer Gianluca Pinoli <gianluca.pinoli@gmail.com> - 2011-08-19 03:23 -0700
      Re: FTP incomplete file transfer CMc <cmccaul@ruddwisdom.com> - 2011-08-19 05:59 -0700
    Re: FTP incomplete file transfer Mario Schulz <info@removethiswegenspamundsoconcept-dv.de> - 2011-08-22 09:42 +0200
    Re: FTP incomplete file transfer "Jamal" <vodotnet_nospam@yahoo.com> - 2011-08-31 17:30 -0400
      Re: FTP incomplete file transfer CMc <cmccaul@ruddwisdom.com> - 2011-08-31 19:16 -0700
        Re: FTP incomplete file transfer "Jamal" <vodotnet_nospam@yahoo.com> - 2011-09-01 11:52 -0400
          Re: FTP incomplete file transfer CMc <cmccaul@ruddwisdom.com> - 2011-09-05 16:18 -0700
      Re: FTP incomplete file transfer Gianluca Pinoli <gianluca.pinoli@gmail.com> - 2011-09-01 01:25 -0700

#1802 — FTP incomplete file transfer

FromCMc <cmccaul@ruddwisdom.com>
Date2011-08-09 08:54 -0700
SubjectFTP incomplete file transfer
Message-ID<01745c6b-8c43-43ec-9c5e-dfd5c18cc05a@b34g2000yqi.googlegroups.com>
We have a routine in our system to zip all necessary data files and
send the zip file via ftp to our site for offsite storage.  This code
is working fine for a dozen or so clients.  A few months ago, after a
client recovered from a server crash, the ftp transfer is incomplete
and we are consistently missing the last 3-5% of the .zip file.  This
is the only client where we have this problem.  File sizes range from
10MB or so up to 400MB.  Here's a snippet from the file transfer
method:

oFtp := CFtp{ "Offsite Backup", 21 }	&& FTP via port 21, using the
Internet SDK, VO 2.7b
IF !oFtp:ConnectRemote( cFTPServer, cFTPUserName, cFTPPassword )
	ErrorBox{ , "Could not connect to FTP Server.  Cannot transfer backup
data." }:Show()
	oFtp := NULL_OBJECT
	RETURN FALSE
ENDIF

IF cFTPServer <> kFTPLocation .OR. oFtp:SetCurDir( "/upload" )
	oFtp:DeleteFile(cFTPFile)
	hfLocal := FOpen(cDir+cFTPFile)
	nSize := FSeek(hfLocal,0,FS_END)
	FSeek(hfLocal,0)
	hfFTP := oFtp:OpenFile(cFTPFile, DWORD(_CAST, GENERIC_WRITE) )
	pBuff := MemAlloc(MAX_BUFF_SIZE)
	IF (hfFTP != NULL_PTR .AND. hfLocal != NULL_PTR)
		SELF:winProgress:ProgressInit("QL.Admin Offsite Backup", "Sending "
+ cFTPFile + " to " + cFTPServer)
     		dwLastPos := DWORD(_CAST, Integer(nSize/MAX_BUFF_SIZE)+2 )
     		dwPos := 1
     		nSize := 0
		WHILE TRUE
         			n := FRead3(hfLocal, pBuff, MAX_BUFF_SIZE )
			IF n > 0
				i := n
				IF !InternetWriteFile(hfFTP, pBuff, n, @i)
					EXIT
			                ENDIF
				nSize := nSize+n
			ELSE
				EXIT
			ENDIF
			SELF:winProgress:BarAdvance(dwPos++, dwLastPos)
		END
		oFtp:CloseFile(hfFTP)
		FClose(hfLocal)
		lRet := TRUE
   	ELSE
		SELF:RaiseFTPError(oFtp)
   	ENDIF
   	MemFree(pBuff)
ENDIF
oFtp:CloseRemote()

I have logged the transfer progress and the InternetWriteFile returns
information that indicates we are sending the complete file with no
errors during the process, but I end up with an incomplete file every
time from just this one client.  It's almost as if the last bit of the
file is buffered somewhere in the transmission and we're closing the
file and connection before the transmission is complete.

Any suggestions?

Thanks in advance for your help.

[toc] | [next] | [standalone]


#1803

FromD.J.W. van Kooten <public@ic2remove.this.com>
Date2011-08-09 18:45 +0200
Message-ID<bso247hn896mi4ugk7tf4pprn5h4mfeh29@4ax.com>
In reply to#1802
On Tue, 9 Aug 2011 08:54:59 -0700 (PDT), CMc <cmccaul@ruddwisdom.com>
wrote:


Hello cmc...

>
>Any suggestions?
>
>Thanks in advance for your help.

Not directly. I;ve compared the code with what we do:

DO WHILE n = MAX_BUFF_SIZE
IF !InternetReadFile(hfFTP, pBuff, MAX_BUFF_SIZE, @n)
ENDIF
IF n > 0
	FWrite3(hfLocal, pBuff, n)
ENDIF
++nCount
IF !IsNil(oControl)
	oControl:Caption:=cText+" "+Str(((nCount/nRange)*100),6,2)+"%"
ENDIF
ogApp:Exec(EXECWHILEEVENT)
ENDDO
FClose(hfLocal)
ELSE
SELF:oFTP:Error := ERROR_INTERNET_INVALID_OPERATION
ENDIF	
ENDIF
SELF:oFTP:CloseFile(hfFTP)
MemFree(pBuff)

I basically only see some differences in the order of closing and
freeing. You may want to give that a try. Or use a general FTP program
to see if it fails there too (then it's the client's problem).

Dick

[toc] | [prev] | [next] | [standalone]


#1852

FromSteveMcNaughton <stevemcnaughton@auditron.com>
Date2011-08-18 09:49 -0700
Message-ID<e2d740ad-fb21-414d-a0e5-dfad28bbc6b3@o11g2000yql.googlegroups.com>
In reply to#1802
CMc <cmcc...@ruddwisdom.com>

I've seen the same thing in a few of our sites.  90% of the time it's
the WINDOWS firewall that does it somehow.  IF I disable it, the
transfer works.  Look at the properties of your adapter and see if it
says 'firewalled'.  If so, try disabling it and re-running it.  If it
works, then try changing the settings there.

I do have 1 client that I have this problem with and just can't figure
out why, even with no firewall.  It's almost like the last transfer
buffers won't empty or something.

GLTY

[toc] | [prev] | [next] | [standalone]


#1854

FromGianluca Pinoli <gianluca.pinoli@gmail.com>
Date2011-08-19 03:23 -0700
Message-ID<5ab67e7e-a8a1-4e68-8280-3264135ccb16@k3g2000vbz.googlegroups.com>
In reply to#1802
On 9 Ago, 17:54, CMc <cmcc...@ruddwisdom.com> wrote:
> We have a routine in our system to zip all necessary data files and
> send the zip file via ftp to our site for offsite storage.  This code
> is working fine for a dozen or so clients.  A few months ago, after a
> client recovered from a server crash, the ftp transfer is incomplete
> and we are consistently missing the last 3-5% of the .zip file.  This
> is the only client where we have this problem.  File sizes range from
> 10MB or so up to 400MB.  Here's a snippet from the file transfer
> method:
>
> oFtp := CFtp{ "Offsite Backup", 21 }  && FTP via port 21, using the
> Internet SDK, VO 2.7b
> IF !oFtp:ConnectRemote( cFTPServer, cFTPUserName, cFTPPassword )
>         ErrorBox{ , "Could not connect to FTP Server.  Cannot transfer backup
> data." }:Show()
>         oFtp := NULL_OBJECT
>         RETURN FALSE
> ENDIF
>
> IF cFTPServer <> kFTPLocation .OR. oFtp:SetCurDir( "/upload" )
>         oFtp:DeleteFile(cFTPFile)
>         hfLocal := FOpen(cDir+cFTPFile)
>         nSize := FSeek(hfLocal,0,FS_END)
>         FSeek(hfLocal,0)
>         hfFTP := oFtp:OpenFile(cFTPFile, DWORD(_CAST, GENERIC_WRITE) )
>         pBuff := MemAlloc(MAX_BUFF_SIZE)
>         IF (hfFTP != NULL_PTR .AND. hfLocal != NULL_PTR)
>                 SELF:winProgress:ProgressInit("QL.Admin Offsite Backup", "Sending "
> + cFTPFile + " to " + cFTPServer)
>                 dwLastPos := DWORD(_CAST, Integer(nSize/MAX_BUFF_SIZE)+2 )
>                 dwPos := 1
>                 nSize := 0
>                 WHILE TRUE
>                                 n := FRead3(hfLocal, pBuff, MAX_BUFF_SIZE )
>                         IF n > 0
>                                 i := n
>                                 IF !InternetWriteFile(hfFTP, pBuff, n, @i)
>                                         EXIT
>                                         ENDIF
>                                 nSize := nSize+n
>                         ELSE
>                                 EXIT
>                         ENDIF
>                         SELF:winProgress:BarAdvance(dwPos++, dwLastPos)
>                 END
>                 oFtp:CloseFile(hfFTP)
>                 FClose(hfLocal)
>                 lRet := TRUE
>         ELSE
>                 SELF:RaiseFTPError(oFtp)
>         ENDIF
>         MemFree(pBuff)
> ENDIF
> oFtp:CloseRemote()
>
> I have logged the transfer progress and the InternetWriteFile returns
> information that indicates we are sending the complete file with no
> errors during the process, but I end up with an incomplete file every
> time from just this one client.  It's almost as if the last bit of the
> file is buffered somewhere in the transmission and we're closing the
> file and connection before the transmission is complete.
>
> Any suggestions?
>
> Thanks in advance for your help.

Hi,
I solved a similar problem comparing the the size of the original file
with the transfered one.
Regards
Gianluca

[toc] | [prev] | [next] | [standalone]


#1856

FromCMc <cmccaul@ruddwisdom.com>
Date2011-08-19 05:59 -0700
Message-ID<40da7b0b-b1ad-49bb-af0b-98f8676ab60b@r12g2000vbe.googlegroups.com>
In reply to#1854
On Aug 19, 5:23 am, Gianluca Pinoli <gianluca.pin...@gmail.com> wrote:
> On 9 Ago, 17:54, CMc <cmcc...@ruddwisdom.com> wrote:
>
>
>
>
>
> > We have a routine in our system to zip all necessary data files and
> > send the zip file via ftp to our site for offsite storage.  This code
> > is working fine for a dozen or so clients.  A few months ago, after a
> > client recovered from a server crash, the ftp transfer is incomplete
> > and we are consistently missing the last 3-5% of the .zip file.  This
> > is the only client where we have this problem.  File sizes range from
> > 10MB or so up to 400MB.  Here's a snippet from the file transfer
> > method:
>
> > oFtp := CFtp{ "Offsite Backup", 21 }  && FTP via port 21, using the
> > Internet SDK, VO 2.7b
> > IF !oFtp:ConnectRemote( cFTPServer, cFTPUserName, cFTPPassword )
> >         ErrorBox{ , "Could not connect to FTP Server.  Cannot transfer backup
> > data." }:Show()
> >         oFtp := NULL_OBJECT
> >         RETURN FALSE
> > ENDIF
>
> > IF cFTPServer <> kFTPLocation .OR. oFtp:SetCurDir( "/upload" )
> >         oFtp:DeleteFile(cFTPFile)
> >         hfLocal := FOpen(cDir+cFTPFile)
> >         nSize := FSeek(hfLocal,0,FS_END)
> >         FSeek(hfLocal,0)
> >         hfFTP := oFtp:OpenFile(cFTPFile, DWORD(_CAST, GENERIC_WRITE) )
> >         pBuff := MemAlloc(MAX_BUFF_SIZE)
> >         IF (hfFTP != NULL_PTR .AND. hfLocal != NULL_PTR)
> >                 SELF:winProgress:ProgressInit("QL.Admin Offsite Backup", "Sending "
> > + cFTPFile + " to " + cFTPServer)
> >                 dwLastPos := DWORD(_CAST, Integer(nSize/MAX_BUFF_SIZE)+2 )
> >                 dwPos := 1
> >                 nSize := 0
> >                 WHILE TRUE
> >                                 n := FRead3(hfLocal, pBuff, MAX_BUFF_SIZE )
> >                         IF n > 0
> >                                 i := n
> >                                 IF !InternetWriteFile(hfFTP, pBuff, n, @i)
> >                                         EXIT
> >                                         ENDIF
> >                                 nSize := nSize+n
> >                         ELSE
> >                                 EXIT
> >                         ENDIF
> >                         SELF:winProgress:BarAdvance(dwPos++, dwLastPos)
> >                 END
> >                 oFtp:CloseFile(hfFTP)
> >                 FClose(hfLocal)
> >                 lRet := TRUE
> >         ELSE
> >                 SELF:RaiseFTPError(oFtp)
> >         ENDIF
> >         MemFree(pBuff)
> > ENDIF
> > oFtp:CloseRemote()
>
> > I have logged the transfer progress and the InternetWriteFile returns
> > information that indicates we are sending the complete file with no
> > errors during the process, but I end up with an incomplete file every
> > time from just this one client.  It's almost as if the last bit of the
> > file is buffered somewhere in the transmission and we're closing the
> > file and connection before the transmission is complete.
>
> > Any suggestions?
>
> > Thanks in advance for your help.
>
> Hi,
> I solved a similar problem comparing the the size of the original file
> with the transfered one.
> Regards
> Gianluca- Hide quoted text -
>
> - Show quoted text -

Steve,

Thanks for the response, but the adapters are not firewalled.  I tried
the code from two different machines (server and workstation) and
neither are firewalled.

Gianluca,

Can you elaborate on what you did when comparing the size of the
source and destination files?  I have tried logging the number of
bytes transferred, but the log shows all bytes successfully sent using
InternetWriteFile().  If you compare the size of the source and
destination file and the destination size is different, what do you do
next?  Thanks very much for your help.

Chris

[toc] | [prev] | [next] | [standalone]


#1862

FromMario Schulz <info@removethiswegenspamundsoconcept-dv.de>
Date2011-08-22 09:42 +0200
Message-ID<j2t17t$gna$1@online.de>
In reply to#1802
Hi Cmc,

i had something like that some month ago ( Win7 and Vista )...

i solved by checking the local download path... unc path...

with

\\server01\test\download

i get sometimes not on all clients only the half file...

if i set the local download path to :

f:\test\download...

on the same client ... all fine...

bye,
Mario

[toc] | [prev] | [next] | [standalone]


#1929

From"Jamal" <vodotnet_nospam@yahoo.com>
Date2011-08-31 17:30 -0400
Message-ID<j3m967$kv8$1@dont-email.me>
In reply to#1802
Why not use CFtp:PutFile() ?

Jamal

"CMc"  wrote in message 
news:01745c6b-8c43-43ec-9c5e-dfd5c18cc05a@b34g2000yqi.googlegroups.com...

We have a routine in our system to zip all necessary data files and
send the zip file via ftp to our site for offsite storage.  This code
is working fine for a dozen or so clients.  A few months ago, after a
client recovered from a server crash, the ftp transfer is incomplete
and we are consistently missing the last 3-5% of the .zip file.  This
is the only client where we have this problem.  File sizes range from
10MB or so up to 400MB.  Here's a snippet from the file transfer
method:

oFtp := CFtp{ "Offsite Backup", 21 } && FTP via port 21, using the
Internet SDK, VO 2.7b
IF !oFtp:ConnectRemote( cFTPServer, cFTPUserName, cFTPPassword )
ErrorBox{ , "Could not connect to FTP Server.  Cannot transfer backup
data." }:Show()
oFtp := NULL_OBJECT
RETURN FALSE
ENDIF

IF cFTPServer <> kFTPLocation .OR. oFtp:SetCurDir( "/upload" )
oFtp:DeleteFile(cFTPFile)
hfLocal := FOpen(cDir+cFTPFile)
nSize := FSeek(hfLocal,0,FS_END)
FSeek(hfLocal,0)
hfFTP := oFtp:OpenFile(cFTPFile, DWORD(_CAST, GENERIC_WRITE) )
pBuff := MemAlloc(MAX_BUFF_SIZE)
IF (hfFTP != NULL_PTR .AND. hfLocal != NULL_PTR)
SELF:winProgress:ProgressInit("QL.Admin Offsite Backup", "Sending "
+ cFTPFile + " to " + cFTPServer)
     dwLastPos := DWORD(_CAST, Integer(nSize/MAX_BUFF_SIZE)+2 )
     dwPos := 1
     nSize := 0
WHILE TRUE
         n := FRead3(hfLocal, pBuff, MAX_BUFF_SIZE )
IF n > 0
i := n
IF !InternetWriteFile(hfFTP, pBuff, n, @i)
EXIT
                ENDIF
nSize := nSize+n
ELSE
EXIT
ENDIF
SELF:winProgress:BarAdvance(dwPos++, dwLastPos)
END
oFtp:CloseFile(hfFTP)
FClose(hfLocal)
lRet := TRUE
   ELSE
SELF:RaiseFTPError(oFtp)
   ENDIF
   MemFree(pBuff)
ENDIF
oFtp:CloseRemote()

I have logged the transfer progress and the InternetWriteFile returns
information that indicates we are sending the complete file with no
errors during the process, but I end up with an incomplete file every
time from just this one client.  It's almost as if the last bit of the
file is buffered somewhere in the transmission and we're closing the
file and connection before the transmission is complete.

Any suggestions?

Thanks in advance for your help. 

[toc] | [prev] | [next] | [standalone]


#1930

FromCMc <cmccaul@ruddwisdom.com>
Date2011-08-31 19:16 -0700
Message-ID<4d4fdae7-919a-4d9b-85f7-ebe48b7d3208@br5g2000vbb.googlegroups.com>
In reply to#1929
On Aug 31, 4:30 pm, "Jamal" <vodotnet_nos...@yahoo.com> wrote:
> Why not use CFtp:PutFile() ?
>
> Jamal
>

I've tried that with the same results.  I'm using the
InternetWriteFile function to be able to display the file transfer
progress.  Either way for this one client, I only get 90-95% of the
file written on our ftp site.

Thanks anyway.

[toc] | [prev] | [next] | [standalone]


#1937

From"Jamal" <vodotnet_nospam@yahoo.com>
Date2011-09-01 11:52 -0400
Message-ID<j3o9nm$5ue$1@dont-email.me>
In reply to#1930
Then may be there a time out issue.

Before the end of your loop, place a DoEvents() function. Also, try to add 
before you close the ftp file and connection.

HTH,
Jamal

"CMc"  wrote in message 
news:4d4fdae7-919a-4d9b-85f7-ebe48b7d3208@br5g2000vbb.googlegroups.com...

On Aug 31, 4:30 pm, "Jamal" <vodotnet_nos...@yahoo.com> wrote:
> Why not use CFtp:PutFile() ?
>
> Jamal
>

I've tried that with the same results.  I'm using the
InternetWriteFile function to be able to display the file transfer
progress.  Either way for this one client, I only get 90-95% of the
file written on our ftp site.

Thanks anyway. 

[toc] | [prev] | [next] | [standalone]


#1952

FromCMc <cmccaul@ruddwisdom.com>
Date2011-09-05 16:18 -0700
Message-ID<05eae30b-d775-4cf7-92e8-4df1186d061e@l7g2000vbz.googlegroups.com>
In reply to#1937
Hi Jamal,

Thanks for the suggestion, but it didn't help.  I added a call to
DoEvents() before the end of the loop and before each close (file and
connection) and had the same results.  It really seems like a
configuration or environment issue at the client's site since this
same code works for every other client without any problems.  I am
seeing these incomplete files only at this one client even when trying
to send the files to different destination ftp sites.

Thanks,
Chris

On Sep 1, 10:52 am, "Jamal" <vodotnet_nos...@yahoo.com> wrote:
> Then may be there a time out issue.
>
> Before the end of your loop, place a DoEvents() function. Also, try to add
> before you close the ftp file and connection.
>
> HTH,
> Jamal
>
> "CMc"  wrote in message
>
> news:4d4fdae7-919a-4d9b-85f7-ebe48b7d3208@br5g2000vbb.googlegroups.com...
>

[toc] | [prev] | [next] | [standalone]


#1932

FromGianluca Pinoli <gianluca.pinoli@gmail.com>
Date2011-09-01 01:25 -0700
Message-ID<60c774cf-094e-415f-b489-032e8034c31e@a27g2000yqc.googlegroups.com>
In reply to#1929
On 31 Ago, 23:30, "Jamal" <vodotnet_nos...@yahoo.com> wrote:
> Why not use CFtp:PutFile() ?
>
> Jamal
>
> "CMc"  wrote in message
>
> news:01745c6b-8c43-43ec-9c5e-dfd5c18cc05a@b34g2000yqi.googlegroups.com...
>
> We have a routine in our system to zip all necessary data files and
> send the zipfileviaftpto our site for offsite storage.  This code
> is working fine for a dozen or so clients.  A few months ago, after a
> client recovered from a server crash, theftptransferisincomplete
> and we are consistently missing the last 3-5% of the .zipfile.  This
> is the only client where we have this problem.  Filesizes range from
> 10MB or so up to 400MB.  Here's a snippet from thefiletransfer
> method:
>
> oFtp := CFtp{ "Offsite Backup", 21 } &&FTPvia port 21, using the
> Internet SDK, VO 2.7b
> IF !oFtp:ConnectRemote( cFTPServer, cFTPUserName, cFTPPassword )
> ErrorBox{ , "Could not connect toFTPServer.  Cannottransferbackup
> data." }:Show()
> oFtp := NULL_OBJECT
> RETURN FALSE
> ENDIF
>
> IF cFTPServer <> kFTPLocation .OR. oFtp:SetCurDir( "/upload" )
> oFtp:DeleteFile(cFTPFile)
> hfLocal := FOpen(cDir+cFTPFile)
> nSize := FSeek(hfLocal,0,FS_END)
> FSeek(hfLocal,0)
> hfFTP := oFtp:OpenFile(cFTPFile, DWORD(_CAST, GENERIC_WRITE) )
> pBuff := MemAlloc(MAX_BUFF_SIZE)
> IF (hfFTP != NULL_PTR .AND. hfLocal != NULL_PTR)
> SELF:winProgress:ProgressInit("QL.Admin Offsite Backup", "Sending "
> + cFTPFile + " to " + cFTPServer)
>      dwLastPos := DWORD(_CAST, Integer(nSize/MAX_BUFF_SIZE)+2 )
>      dwPos := 1
>      nSize := 0
> WHILE TRUE
>          n := FRead3(hfLocal, pBuff, MAX_BUFF_SIZE )
> IF n > 0
> i := n
> IF !InternetWriteFile(hfFTP, pBuff, n, @i)
> EXIT
>                 ENDIF
> nSize := nSize+n
> ELSE
> EXIT
> ENDIF
> SELF:winProgress:BarAdvance(dwPos++, dwLastPos)
> END
> oFtp:CloseFile(hfFTP)
> FClose(hfLocal)
> lRet := TRUE
>    ELSE
> SELF:RaiseFTPError(oFtp)
>    ENDIF
>    MemFree(pBuff)
> ENDIF
> oFtp:CloseRemote()
>
> I have logged thetransferprogress and the InternetWriteFile returns
> information that indicates we are sending the completefilewith no
> errors during the process, but I end up with anincompletefileevery
> time from just this one client.  It's almost as if the last bit of thefileis buffered somewhere in the transmission and we're closing thefileand connection before the transmission is complete.
>
> Any suggestions?
>
> Thanks in advance for your help.



This is my (empirical) solution of the same problem.
I check the dimension of the local and remote file, and if there are
differences i send the file again.

METHOD PutLowLevel      (cFile, nSize)		CLASS RASWin
    LOCAL hfFTP                     AS PTR
    LOCAL lRet := FALSE             AS LOGIC
    LOCAL n                         AS DWORD
    LOCAL hfLocal                   AS PTR
    LOCAL DIM abBuff[MAX_BUFF_SIZE] AS BYTE
    LOCAL sPercorsoFile AS STRING

    LOCAL nRange := 0 AS INT
    LOCAL nStepRange := 1 AS INT
    LOCAL nProgRange := 0 AS INT


    lRet := FALSE

    sPercorsoFile := AllTrim(GooseIniFS:GetString(sNodo,"FTP_Outbox"))
    IF Right(sPercorsoFile,1) != '\'
	sPercorsoFile += '\'
    ENDIF

    hfLocal := FOpen(sPercorsoFile + "\" + cFile)

    IF hfLocal != NULL_PTR

        hfFTP := SELF:oFTPgoose:OpenFile( cFile, GENERIC_WRITE )

        IF hfFTP != NULL_PTR
            n := MAX_BUFF_SIZE
            lRet := TRUE

            nRange := Integer(nSize/n)
            nStepRange := 1
            WHILE nRange > 65000
            	nRange := nRange / 2
            	nStepRange := nStepRange*2
            END


	   SELF:oDCFTPBar:Range := Range{1, nRange + 2 }
   	   SELF:oDCFTPBar:Show()

            DO WHILE n = MAX_BUFF_SIZE
            	nProgRange++
            	IF nProgRange>= nStepRange
                      nProgRange := 0
           	    SELF:oDCFTPBar:Advance(1)
           	ENDIF
		n := FRead3(hfLocal, @abBuff[1], n)
                  IF n > 0
                    IF !InternetWriteFile(hfFTP, @abBuff[1], n, @n)
                   	SELF:oFTPgoose:Error := GetLastError()
			SELF:oDCFTPBar:Position := 0
			FClose(hfLocal)
			RETURN FALSE
		  ENDIF
                  ENDIF

		GetAppObject():Exec(EXECWHILEEVENT)
		IF SELF:lAnnullaTrasmissione
		    SELF:oDCFTPBar:Position := 0
		    FClose(hfLocal)
		    RETURN FALSE
	         ENDIF
            ENDDO
   	   SELF:oDCFTPBar:Position := 0


	   SELF:oFTPgoose:CloseFile(hfFTP)


            //04-04-2008
            IF nSize != SELF:GetFileSizeIn( cFile )
		//check if the size of the local file isn't the same of the remote
one
	         lRet := FALSE
		SELF:oFTPgoose:Error := ERROR_INTERNET_INVALID_OPERATION
	   ENDIF


	ELSE
	   SELF:oFTPgoose:Error := ERROR_INTERNET_INVALID_OPERATION
        ENDIF
        FClose(hfLocal)
    ELSE
       	lRet := FALSE
    ENDIF


RETURN lRet

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web