So I have serious problems. I am on vacation in Mexico and my employees back in the United States report that they can't fill orders.
I've found the suspect code to be this function:
Public Sub FtpPutFileEx( _
ByVal szServer As String, _
ByVal szUser As String, _
ByVal szPassword As String, _
ByVal szLocalFile As String, _
ByVal szServerFile As String)
Dim dwStatus As Long
Dim dwLoFileSize As Long
Dim dwHiFileSize As Long
Dim dwPercent As Long
hOpen = InternetOpenW(0, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0)
'// connect to the ftp server
hConnect = InternetConnectW(hOpen, StrPtr(szServer), INTERNET_DEFAULT_FTP_PORT, StrPtr(szUser), StrPtr(szPassword), INTERNET_SERVICE_FTP, 0, 0)
If hConnect = 0 Then
Debug.Print "InternetConnectW()" & Err.LastDllError
'// get handle for filename that will be written to the ftp server
hInternet = FtpOpenFileW(hConnect, StrPtr(szServerFile), GENERIC_WRITE, FTP_TRANSFER_TYPE_UNKNOWN, 0)
If hInternet = 0 Then
Debug.Print "FtpOpenFile()" & Err.LastDllError
'// get handle for local file to read bytes
hFile = CreateFileW(StrPtr("\\?\" & szLocalFile), GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)
If hFile = INVALID_HANDLE_VALUE Then
MsgBox "CreateFileW()" & Err.LastDllError
' // get local file size for progress. This example supports
' only up to 2GB of status reporting progress.
dwLoFileSize = GetFileSize(hFile, dwHiFileSize)
'// read local file, write server file bytes
If ReadFile(hFile, VarPtr(Buffer(0)), BUF_SIZE, dwReadBytes, 0) Then
If InternetWriteFile(hInternet, VarPtr(Buffer(0)), dwReadBytes, dwWrittenBytes) Then
' Track the amount of bytes written and percentage.
dwStatus = (dwStatus + dwWrittenBytes)
dwPercent = (dwStatus / dwLoFileSize) * 100
'Label1.Caption = dwPercent
Loop Until dwReadBytes = 0
'MsgBox "Done Uploading"
This has worked just fine for years.
I don't know what would cause it to stop working. And it's doing the same thing on multiple machines. It doesn't throw an error, it simply hangs for like 5 minutes and then continues as if it uploaded the file, but it did't.
Does anyone know how to fix this or possibly even scrap it and do another method of ftp from within VB6?