f



WinInet File Uploading dies after 3 files and 4th is created with 0 byte size

I have an FTP transfer utility that is dying (program totally aborts without
error) after 3 files are uploaded and the 4th is created on the FTP site
with a 0 byte size.  Any ideas why?

The program basically switches to an outbound folder and processes the *.std
files one at a time, putting each file in a zip and then uploading the zip
to the remote ftp site.  The local zip is deleted and the std file is moved
to an archive folder.

For some reason, the first 3 are processed perfectly but then the 4th file
is created on the ftp site but no bytes get transmitted and my FTP EXE shuts
down without warning.  What could cause this?  Timing?  Lost connection?

Here's the upload code which was slightly modified from Ron Schofield's AFT
example:

!---------------------------------------------------------------------------
-------------------------------!
UploadFile
PROCEDURE(*FTPHandle,*LocalPath,*RemotePath,*Filename,*STDFileName)
!---------------------------------------------------------------------------
-------------------------------!

RemoteFileHandle    ULONG
LocalFileHandle     ULONG
FTPTransferType     ULONG(FTP_TRANSFER_TYPE_BINARY)
LocalFilename       CSTRING(FILE:MaxFilePath)
RemoteFilename      CSTRING(2048)
DataBuffer          CSTRING(129)
LocalBytesToRead    ULONG(128)
LocalBytesRead      ULONG
RemoteBytesWritten  ULONG
TotalBytesWritten   ULONG
FileSize            LONG(0)
JobName             CSTRING(9)
ReturnError         LONG(0)

TransferWindow WINDOW,AT(,,185,57),FONT('Tahoma',10,,),CENTER,GRAY,DOUBLE
       IMAGE('cmsftp.ico'),AT(6,9),USE(?Image1)
       STRING('Transferring
File'),AT(29,6),USE(?TransferString),TRN,FONT('Tahoma',10,,FONT:regular)
       PROGRESS,USE(?ProgressBar),AT(29,16,148,10),RANGE(0,100)
       PROMPT('File:'),AT(31,31,14,10),USE(?Prompt1)
       STRING(@s20),AT(49,31,84,10),USE(FileName)
       PROMPT('To:'),AT(33,44,12,10),USE(?Prompt2)
       STRING(@s20),AT(49,44),USE(JobName)
     END

CODE

  LocalFilename = CLIP(LocalPath) & '\' & Filename
  FileSize = GetFileSize(LocalFileName)
  JobName = STDFileName[1:8]
  RemoteFilename = CLIP(RemotePath) & '/' & JobName
  RemoteFileHandle =
FTPOpenFile(FTPHandle,RemoteFilename,GENERIC_WRITE,FTPTransferType,0)
  IF RemoteFileHandle
    LocalFileHandle =
CreateFile(LocalFilename,GENERIC_READ,0,0,OPEN_EXISTING,0,0)
    IF LocalFileHandle
      OPEN(TransferWindow)
      SETCURSOR(CURSOR:Wait)
      ?ProgressBar{PROP:RangeHigh} = FileSize
      DISPLAY()
      LOOP
        IF
ReadFile(LocalFileHandle,DataBuffer,LocalBytesToRead,LocalBytesRead,0)
           IF LocalBytesRead = 0
              CLOSE(TransferWindow)
              CloseHandle(LocalFileHandle)
              DO ProcedureReturn
           ELSE

InternetWriteFile(RemoteFileHandle,DataBuffer,LocalBytesRead,RemoteBytesWrit
ten)
              TotalBytesWritten += RemoteBytesWritten
              ?ProgressBar{PROP:Progress} = TotalBytesWritten
              DISPLAY()
           END
        ELSE
           CLOSE(TransferWindow)
           CloseHandle(LocalFileHandle)
           BREAK
        END
      END
    ELSE
      stop('no local file handle')
      DO ProcedureReturn
    END
  ELSE
    ReturnError = GetLastError()
    BEEP(BEEP:SystemExclamation)  ;  YIELD() ; SETCURSOR
    MESSAGE('An error occurred while attempting to upload a file.'&|
            '||File: '&LocalFileName&'||Error: '&ReturnError, |
            'File Upload Error', ICON:Exclamation)
    SETCURSOR
    RETURN(ReturnError)
  END

!=======================!
ProcedureReturn ROUTINE !
!=======================!

  InternetCloseHandle(RemoteFileHandle)
  SETCURSOR
  RETURN(ReturnError)


Greg Berthume


0
greg3760 (74)
7/15/2003 8:02:07 PM
comp.lang.clarion 5469 articles. 4 followers. Post Follow

5 Replies
10871 Views

Similar Articles

[PageSpeed] 20

Something going on in the zip procedure...

"Greg Berthume" <greg@berthume.com> wrote in message
news:3f145dbe$1@news.softvelocity.com...
> I have an FTP transfer utility that is dying (program totally aborts
without
> error) after 3 files are uploaded and the 4th is created on the FTP site
> with a 0 byte size.  Any ideas why?
>
> The program basically switches to an outbound folder and processes the
*.std
> files one at a time, putting each file in a zip and then uploading the zip
> to the remote ftp site.  The local zip is deleted and the std file is
moved
> to an archive folder.
>
> For some reason, the first 3 are processed perfectly but then the 4th file
> is created on the ftp site but no bytes get transmitted and my FTP EXE
shuts
> down without warning.  What could cause this?  Timing?  Lost connection?
>
> Here's the upload code which was slightly modified from Ron Schofield's
AFT
> example:
>
>
!---------------------------------------------------------------------------
> -------------------------------!
> UploadFile
> PROCEDURE(*FTPHandle,*LocalPath,*RemotePath,*Filename,*STDFileName)
>
!---------------------------------------------------------------------------
> -------------------------------!
>
> RemoteFileHandle    ULONG
> LocalFileHandle     ULONG
> FTPTransferType     ULONG(FTP_TRANSFER_TYPE_BINARY)
> LocalFilename       CSTRING(FILE:MaxFilePath)
> RemoteFilename      CSTRING(2048)
> DataBuffer          CSTRING(129)
> LocalBytesToRead    ULONG(128)
> LocalBytesRead      ULONG
> RemoteBytesWritten  ULONG
> TotalBytesWritten   ULONG
> FileSize            LONG(0)
> JobName             CSTRING(9)
> ReturnError         LONG(0)
>
> TransferWindow WINDOW,AT(,,185,57),FONT('Tahoma',10,,),CENTER,GRAY,DOUBLE
>        IMAGE('cmsftp.ico'),AT(6,9),USE(?Image1)
>        STRING('Transferring
> File'),AT(29,6),USE(?TransferString),TRN,FONT('Tahoma',10,,FONT:regular)
>        PROGRESS,USE(?ProgressBar),AT(29,16,148,10),RANGE(0,100)
>        PROMPT('File:'),AT(31,31,14,10),USE(?Prompt1)
>        STRING(@s20),AT(49,31,84,10),USE(FileName)
>        PROMPT('To:'),AT(33,44,12,10),USE(?Prompt2)
>        STRING(@s20),AT(49,44),USE(JobName)
>      END
>
> CODE
>
>   LocalFilename = CLIP(LocalPath) & '\' & Filename
>   FileSize = GetFileSize(LocalFileName)
>   JobName = STDFileName[1:8]
>   RemoteFilename = CLIP(RemotePath) & '/' & JobName
>   RemoteFileHandle =
> FTPOpenFile(FTPHandle,RemoteFilename,GENERIC_WRITE,FTPTransferType,0)
>   IF RemoteFileHandle
>     LocalFileHandle =
> CreateFile(LocalFilename,GENERIC_READ,0,0,OPEN_EXISTING,0,0)
>     IF LocalFileHandle
>       OPEN(TransferWindow)
>       SETCURSOR(CURSOR:Wait)
>       ?ProgressBar{PROP:RangeHigh} = FileSize
>       DISPLAY()
>       LOOP
>         IF
> ReadFile(LocalFileHandle,DataBuffer,LocalBytesToRead,LocalBytesRead,0)
>            IF LocalBytesRead = 0
>               CLOSE(TransferWindow)
>               CloseHandle(LocalFileHandle)
>               DO ProcedureReturn
>            ELSE
>
>
InternetWriteFile(RemoteFileHandle,DataBuffer,LocalBytesRead,RemoteBytesWrit
> ten)
>               TotalBytesWritten += RemoteBytesWritten
>               ?ProgressBar{PROP:Progress} = TotalBytesWritten
>               DISPLAY()
>            END
>         ELSE
>            CLOSE(TransferWindow)
>            CloseHandle(LocalFileHandle)
>            BREAK
>         END
>       END
>     ELSE
>       stop('no local file handle')
>       DO ProcedureReturn
>     END
>   ELSE
>     ReturnError = GetLastError()
>     BEEP(BEEP:SystemExclamation)  ;  YIELD() ; SETCURSOR
>     MESSAGE('An error occurred while attempting to upload a file.'&|
>             '||File: '&LocalFileName&'||Error: '&ReturnError, |
>             'File Upload Error', ICON:Exclamation)
>     SETCURSOR
>     RETURN(ReturnError)
>   END
>
> !=======================!
> ProcedureReturn ROUTINE !
> !=======================!
>
>   InternetCloseHandle(RemoteFileHandle)
>   SETCURSOR
>   RETURN(ReturnError)
>
>
> Greg Berthume
>
>


0
greg3760 (74)
7/15/2003 9:13:13 PM
memory leak in lszip.  needed to download the update that fixed it....

"Greg Berthume" <greg@berthume.com> wrote in message
news:3f146e67$1@news.softvelocity.com...
> Something going on in the zip procedure...
>
> "Greg Berthume" <greg@berthume.com> wrote in message
> news:3f145dbe$1@news.softvelocity.com...
> > I have an FTP transfer utility that is dying (program totally aborts
> without
> > error) after 3 files are uploaded and the 4th is created on the FTP site
> > with a 0 byte size.  Any ideas why?
> >
> > The program basically switches to an outbound folder and processes the
> *.std
> > files one at a time, putting each file in a zip and then uploading the
zip
> > to the remote ftp site.  The local zip is deleted and the std file is
> moved
> > to an archive folder.
> >
> > For some reason, the first 3 are processed perfectly but then the 4th
file
> > is created on the ftp site but no bytes get transmitted and my FTP EXE
> shuts
> > down without warning.  What could cause this?  Timing?  Lost connection?
> >
> > Here's the upload code which was slightly modified from Ron Schofield's
> AFT
> > example:
> >
> >
>
!---------------------------------------------------------------------------
> > -------------------------------!
> > UploadFile
> > PROCEDURE(*FTPHandle,*LocalPath,*RemotePath,*Filename,*STDFileName)
> >
>
!---------------------------------------------------------------------------
> > -------------------------------!
> >
> > RemoteFileHandle    ULONG
> > LocalFileHandle     ULONG
> > FTPTransferType     ULONG(FTP_TRANSFER_TYPE_BINARY)
> > LocalFilename       CSTRING(FILE:MaxFilePath)
> > RemoteFilename      CSTRING(2048)
> > DataBuffer          CSTRING(129)
> > LocalBytesToRead    ULONG(128)
> > LocalBytesRead      ULONG
> > RemoteBytesWritten  ULONG
> > TotalBytesWritten   ULONG
> > FileSize            LONG(0)
> > JobName             CSTRING(9)
> > ReturnError         LONG(0)
> >
> > TransferWindow
WINDOW,AT(,,185,57),FONT('Tahoma',10,,),CENTER,GRAY,DOUBLE
> >        IMAGE('cmsftp.ico'),AT(6,9),USE(?Image1)
> >        STRING('Transferring
> > File'),AT(29,6),USE(?TransferString),TRN,FONT('Tahoma',10,,FONT:regular)
> >        PROGRESS,USE(?ProgressBar),AT(29,16,148,10),RANGE(0,100)
> >        PROMPT('File:'),AT(31,31,14,10),USE(?Prompt1)
> >        STRING(@s20),AT(49,31,84,10),USE(FileName)
> >        PROMPT('To:'),AT(33,44,12,10),USE(?Prompt2)
> >        STRING(@s20),AT(49,44),USE(JobName)
> >      END
> >
> > CODE
> >
> >   LocalFilename = CLIP(LocalPath) & '\' & Filename
> >   FileSize = GetFileSize(LocalFileName)
> >   JobName = STDFileName[1:8]
> >   RemoteFilename = CLIP(RemotePath) & '/' & JobName
> >   RemoteFileHandle =
> > FTPOpenFile(FTPHandle,RemoteFilename,GENERIC_WRITE,FTPTransferType,0)
> >   IF RemoteFileHandle
> >     LocalFileHandle =
> > CreateFile(LocalFilename,GENERIC_READ,0,0,OPEN_EXISTING,0,0)
> >     IF LocalFileHandle
> >       OPEN(TransferWindow)
> >       SETCURSOR(CURSOR:Wait)
> >       ?ProgressBar{PROP:RangeHigh} = FileSize
> >       DISPLAY()
> >       LOOP
> >         IF
> > ReadFile(LocalFileHandle,DataBuffer,LocalBytesToRead,LocalBytesRead,0)
> >            IF LocalBytesRead = 0
> >               CLOSE(TransferWindow)
> >               CloseHandle(LocalFileHandle)
> >               DO ProcedureReturn
> >            ELSE
> >
> >
>
InternetWriteFile(RemoteFileHandle,DataBuffer,LocalBytesRead,RemoteBytesWrit
> > ten)
> >               TotalBytesWritten += RemoteBytesWritten
> >               ?ProgressBar{PROP:Progress} = TotalBytesWritten
> >               DISPLAY()
> >            END
> >         ELSE
> >            CLOSE(TransferWindow)
> >            CloseHandle(LocalFileHandle)
> >            BREAK
> >         END
> >       END
> >     ELSE
> >       stop('no local file handle')
> >       DO ProcedureReturn
> >     END
> >   ELSE
> >     ReturnError = GetLastError()
> >     BEEP(BEEP:SystemExclamation)  ;  YIELD() ; SETCURSOR
> >     MESSAGE('An error occurred while attempting to upload a file.'&|
> >             '||File: '&LocalFileName&'||Error: '&ReturnError, |
> >             'File Upload Error', ICON:Exclamation)
> >     SETCURSOR
> >     RETURN(ReturnError)
> >   END
> >
> > !=======================!
> > ProcedureReturn ROUTINE !
> > !=======================!
> >
> >   InternetCloseHandle(RemoteFileHandle)
> >   SETCURSOR
> >   RETURN(ReturnError)
> >
> >
> > Greg Berthume
> >
> >
>
>


0
greg3760 (74)
7/15/2003 10:04:19 PM
Hi Greg,

.... These one sided conversations are really starting to work for you!

;-)



Charles Edmonds
cje-ByteMeSpammers-@lansrad.com

LANSRAD - "Intelligent Solutions for Universal Problems"
www.lansrad.com




0
cje (42)
7/16/2003 4:59:08 AM
Sometimes I use the newsgroup to provide myself with technical support.  <G>

"Charles Edmonds" <cje@lansrad.com> wrote in message
news:3f14daea@news.softvelocity.com...
> Hi Greg,
>
> ... These one sided conversations are really starting to work for you!
>
> ;-)
>
>
>
> Charles Edmonds
> cje-ByteMeSpammers-@lansrad.com
>
> LANSRAD - "Intelligent Solutions for Universal Problems"
> www.lansrad.com
>
>
>
>


0
greg3760 (74)
7/16/2003 3:12:52 PM
I use cpTracker as a personal knowledgebase.  I have a separate database
that I switch to and use the Task file to record KB type stuff.  I can then
use query wizard and sorting the task browse by the Category column to
quickly locate solutions / code snippets.   cpTracker can morph into all
sorts of solutions!

"Arnor Baldvinsson" <arnor@icetips.com> wrote in message
news:3f156f53.9737125@news.softvelocity.com...
> Hi Greg,
>
> On Wed, 16 Jul 2003 10:12:52 -0500, "Greg Berthume"
> <greg@berthume.com> wrote:
>
> >Sometimes I use the newsgroup to provide myself with technical support.
>
> Makes up for great resource in the further - all you need to do is
> search the newsgroups looking for your postings<g>
>
> Best regards,
>
> Arn�r Baldvinsson
> Icetips Software
> San Antonio, Texas, USA
> www.icetips.com
> arnor@icetips.com
>
> Subscribe to information from Icetips.com:
> http://www.icetips.com/getnotificationinfo.htm


0
greg3760 (74)
7/16/2003 7:11:18 PM
Reply: