FtpGetFile and FtpPutFile returns false - Please help! 
Author Message
 FtpGetFile and FtpPutFile returns false - Please help!

I have followed the MSDN instructions as much as I can (its written in c++
and I'm trying to write it in vb).
The FTP root is wide open (no permissions necessary).  I also have read and
write permissions set on the home directory.
There are no permissions on the folder itself (everyone has full control).
I also can get and put files using an FTP app (CuteFTP32).
I also have a .bas file with all the declared functions from wininet.dll

Public Function SendRequest(sUrl As String, sMethod As String, bSecure As
Boolean) As String
  Dim hInternetSession As Long
  Dim hInternetConnect As Long
  Dim hFTPFileConnection As Long
  Dim bRet As Integer
  Dim sHeader As String
  Dim sWFD As WIN32_FIND_DATA

  ' default return is blank
  SendRequest = ""

  ' Initialize variables
  hInternetSession = 0
  hInternetConnect = 0
  hFTPFileConnection = 0

  hInternetSession = InternetOpen("Microsoft Internet Explorer",
INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)

  hInternetConnect = InternetConnect(hInternetSession,
"ftp://my.ftpsite.net", INTERNET_INVALID_PORT_NUMBER, vbNullString,
vbNullString, INTERNET_SERVICE_FTP, 0, 0)

    If hInternetConnect Then

        hFTPFileConnection = FtpFindFirstFile(hInternetConnect, "test1.txt",
sWFD, 0, 0)

            If hFTPFileConnection <> 0 Then
            bRet = FtpSetCurrentDirectory(hInternetConnect, "/") 'set to
root directory

                inputspec = "ftp://my.ftpsite.net/test2.txt"
                'inputspec = inputspec & sWFD.cFileName
                outputspec = "c:\txtfiles\test2.txt"
                'outputspec = outputspec & sWFD.cFileName
                Dim bRet2 As Boolean

                bRet2 = FtpGetFile(hInternetConnect, inputspec, outputspec,
True, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)
                bRet2 = FtpPutFile(hInternetConnect, outputspec, inputspec,
FTP_TRANSFER_TYPE_BINARY, 0)

                    If bRet2 Then
                        SendRequest = "ok"
                    Else
                        SendRequest = bRet2
                    End If

                bRet = InternetCloseHandle(hFTPFileConnection)
            End If
        bRet = InternetCloseHandle(hInternetConnect)
    End If
    bRet = InternetCloseHandle(hInternetSession)

End Function



Wed, 22 Sep 2004 00:03:45 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!
This is a SWAG.  I think this is type casting issue with C based BOOL vs
BASIC based BOOLEAN.  I had a similar situation with other imported DLL
functions and I had to check against 0 for FALSE value.

---


Quote:
> I have followed the MSDN instructions as much as I can (its written in c++
> and I'm trying to write it in vb).
> The FTP root is wide open (no permissions necessary).  I also have read
and
> write permissions set on the home directory.
> There are no permissions on the folder itself (everyone has full control).
> I also can get and put files using an FTP app (CuteFTP32).
> I also have a .bas file with all the declared functions from wininet.dll

> Public Function SendRequest(sUrl As String, sMethod As String, bSecure As
> Boolean) As String
>   Dim hInternetSession As Long
>   Dim hInternetConnect As Long
>   Dim hFTPFileConnection As Long
>   Dim bRet As Integer
>   Dim sHeader As String
>   Dim sWFD As WIN32_FIND_DATA

>   ' default return is blank
>   SendRequest = ""

>   ' Initialize variables
>   hInternetSession = 0
>   hInternetConnect = 0
>   hFTPFileConnection = 0

>   hInternetSession = InternetOpen("Microsoft Internet Explorer",
> INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)

>   hInternetConnect = InternetConnect(hInternetSession,
> "ftp://my.ftpsite.net", INTERNET_INVALID_PORT_NUMBER, vbNullString,
> vbNullString, INTERNET_SERVICE_FTP, 0, 0)

>     If hInternetConnect Then

>         hFTPFileConnection = FtpFindFirstFile(hInternetConnect,
"test1.txt",
> sWFD, 0, 0)

>             If hFTPFileConnection <> 0 Then
>             bRet = FtpSetCurrentDirectory(hInternetConnect, "/") 'set to
> root directory

>                 inputspec = "ftp://my.ftpsite.net/test2.txt"
>                 'inputspec = inputspec & sWFD.cFileName
>                 outputspec = "c:\txtfiles\test2.txt"
>                 'outputspec = outputspec & sWFD.cFileName
>                 Dim bRet2 As Boolean

>                 bRet2 = FtpGetFile(hInternetConnect, inputspec,
outputspec,
> True, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)
>                 bRet2 = FtpPutFile(hInternetConnect, outputspec,
inputspec,
> FTP_TRANSFER_TYPE_BINARY, 0)

>                     If bRet2 Then
>                         SendRequest = "ok"
>                     Else
>                         SendRequest = bRet2
>                     End If

>                 bRet = InternetCloseHandle(hFTPFileConnection)
>             End If
>         bRet = InternetCloseHandle(hInternetConnect)
>     End If
>     bRet = InternetCloseHandle(hInternetSession)

> End Function



Wed, 22 Sep 2004 05:04:08 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!
Well regardless of its 0 or False, the files are not transferring either
way, get or put.   I step through the code using the de{*filter*} and it works
fine, but no files transfer.


Quote:
> This is a SWAG.  I think this is type casting issue with C based BOOL vs
> BASIC based BOOLEAN.  I had a similar situation with other imported DLL
> functions and I had to check against 0 for FALSE value.



Wed, 22 Sep 2004 05:07:14 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!
Have you checked GetLastError() after the function calls?

I personally would look at the following as well.

You are using TRUE for Fail If Exist in the FtpGetFile, if the file exist,
it will fail. No file transfer.  Thats why you need to see that
GetLastError() result code when it fails.   Try changing that to TRUE and
see if it works.

Other than that, possible some incorrect prototype interface in the header
file?

------


Quote:
> I have followed the MSDN instructions as much as I can (its written in c++
> and I'm trying to write it in vb).
> The FTP root is wide open (no permissions necessary).  I also have read
and
> write permissions set on the home directory.
> There are no permissions on the folder itself (everyone has full control).
> I also can get and put files using an FTP app (CuteFTP32).
> I also have a .bas file with all the declared functions from wininet.dll

> Public Function SendRequest(sUrl As String, sMethod As String, bSecure As
> Boolean) As String
>   Dim hInternetSession As Long
>   Dim hInternetConnect As Long
>   Dim hFTPFileConnection As Long
>   Dim bRet As Integer
>   Dim sHeader As String
>   Dim sWFD As WIN32_FIND_DATA

>   ' default return is blank
>   SendRequest = ""

>   ' Initialize variables
>   hInternetSession = 0
>   hInternetConnect = 0
>   hFTPFileConnection = 0

>   hInternetSession = InternetOpen("Microsoft Internet Explorer",
> INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)

>   hInternetConnect = InternetConnect(hInternetSession,
> "ftp://my.ftpsite.net", INTERNET_INVALID_PORT_NUMBER, vbNullString,
> vbNullString, INTERNET_SERVICE_FTP, 0, 0)

>     If hInternetConnect Then

>         hFTPFileConnection = FtpFindFirstFile(hInternetConnect,
"test1.txt",
> sWFD, 0, 0)

>             If hFTPFileConnection <> 0 Then
>             bRet = FtpSetCurrentDirectory(hInternetConnect, "/") 'set to
> root directory

>                 inputspec = "ftp://my.ftpsite.net/test2.txt"
>                 'inputspec = inputspec & sWFD.cFileName
>                 outputspec = "c:\txtfiles\test2.txt"
>                 'outputspec = outputspec & sWFD.cFileName
>                 Dim bRet2 As Boolean

>                 bRet2 = FtpGetFile(hInternetConnect, inputspec,
outputspec,
> True, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)
>                 bRet2 = FtpPutFile(hInternetConnect, outputspec,
inputspec,
> FTP_TRANSFER_TYPE_BINARY, 0)

>                     If bRet2 Then
>                         SendRequest = "ok"
>                     Else
>                         SendRequest = bRet2
>                     End If

>                 bRet = InternetCloseHandle(hFTPFileConnection)
>             End If
>         bRet = InternetCloseHandle(hInternetConnect)
>     End If
>     bRet = InternetCloseHandle(hInternetSession)

> End Function



Wed, 22 Sep 2004 07:30:39 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!
GetLastError() doesn't work from VB. Use Err.LastDllError instead.


Quote:
> Have you checked GetLastError() after the function calls?

> I personally would look at the following as well.

> You are using TRUE for Fail If Exist in the FtpGetFile, if the file exist,
> it will fail. No file transfer.  Thats why you need to see that
> GetLastError() result code when it fails.   Try changing that to TRUE and
> see if it works.

> Other than that, possible some incorrect prototype interface in the header
> file?

> ------



> > I have followed the MSDN instructions as much as I can (its written in
c++
> > and I'm trying to write it in vb).
> > The FTP root is wide open (no permissions necessary).  I also have read
> and
> > write permissions set on the home directory.
> > There are no permissions on the folder itself (everyone has full
control).
> > I also can get and put files using an FTP app (CuteFTP32).
> > I also have a .bas file with all the declared functions from wininet.dll

> > Public Function SendRequest(sUrl As String, sMethod As String, bSecure
As
> > Boolean) As String
> >   Dim hInternetSession As Long
> >   Dim hInternetConnect As Long
> >   Dim hFTPFileConnection As Long
> >   Dim bRet As Integer
> >   Dim sHeader As String
> >   Dim sWFD As WIN32_FIND_DATA

> >   ' default return is blank
> >   SendRequest = ""

> >   ' Initialize variables
> >   hInternetSession = 0
> >   hInternetConnect = 0
> >   hFTPFileConnection = 0

> >   hInternetSession = InternetOpen("Microsoft Internet Explorer",
> > INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)

> >   hInternetConnect = InternetConnect(hInternetSession,
> > "ftp://my.ftpsite.net", INTERNET_INVALID_PORT_NUMBER, vbNullString,
> > vbNullString, INTERNET_SERVICE_FTP, 0, 0)

> >     If hInternetConnect Then

> >         hFTPFileConnection = FtpFindFirstFile(hInternetConnect,
> "test1.txt",
> > sWFD, 0, 0)

> >             If hFTPFileConnection <> 0 Then
> >             bRet = FtpSetCurrentDirectory(hInternetConnect, "/") 'set to
> > root directory

> >                 inputspec = "ftp://my.ftpsite.net/test2.txt"
> >                 'inputspec = inputspec & sWFD.cFileName
> >                 outputspec = "c:\txtfiles\test2.txt"
> >                 'outputspec = outputspec & sWFD.cFileName
> >                 Dim bRet2 As Boolean

> >                 bRet2 = FtpGetFile(hInternetConnect, inputspec,
> outputspec,
> > True, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)
> >                 bRet2 = FtpPutFile(hInternetConnect, outputspec,
> inputspec,
> > FTP_TRANSFER_TYPE_BINARY, 0)

> >                     If bRet2 Then
> >                         SendRequest = "ok"
> >                     Else
> >                         SendRequest = bRet2
> >                     End If

> >                 bRet = InternetCloseHandle(hFTPFileConnection)
> >             End If
> >         bRet = InternetCloseHandle(hInternetConnect)
> >     End If
> >     bRet = InternetCloseHandle(hInternetSession)

> > End Function



Wed, 22 Sep 2004 07:43:23 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!
YES it does. it just it gets called, sometimes internally by vb itself when
an api call is issued


Quote:
> GetLastError() doesn't work from VB. Use Err.LastDllError instead.



> > Have you checked GetLastError() after the function calls?

> > I personally would look at the following as well.

> > You are using TRUE for Fail If Exist in the FtpGetFile, if the file
exist,
> > it will fail. No file transfer.  Thats why you need to see that
> > GetLastError() result code when it fails.   Try changing that to TRUE
and
> > see if it works.

> > Other than that, possible some incorrect prototype interface in the
header
> > file?

> > ------



> > > I have followed the MSDN instructions as much as I can (its written in
> c++
> > > and I'm trying to write it in vb).
> > > The FTP root is wide open (no permissions necessary).  I also have
read
> > and
> > > write permissions set on the home directory.
> > > There are no permissions on the folder itself (everyone has full
> control).
> > > I also can get and put files using an FTP app (CuteFTP32).
> > > I also have a .bas file with all the declared functions from
wininet.dll

> > > Public Function SendRequest(sUrl As String, sMethod As String, bSecure
> As
> > > Boolean) As String
> > >   Dim hInternetSession As Long
> > >   Dim hInternetConnect As Long
> > >   Dim hFTPFileConnection As Long
> > >   Dim bRet As Integer
> > >   Dim sHeader As String
> > >   Dim sWFD As WIN32_FIND_DATA

> > >   ' default return is blank
> > >   SendRequest = ""

> > >   ' Initialize variables
> > >   hInternetSession = 0
> > >   hInternetConnect = 0
> > >   hFTPFileConnection = 0

> > >   hInternetSession = InternetOpen("Microsoft Internet Explorer",
> > > INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)

> > >   hInternetConnect = InternetConnect(hInternetSession,
> > > "ftp://my.ftpsite.net", INTERNET_INVALID_PORT_NUMBER, vbNullString,
> > > vbNullString, INTERNET_SERVICE_FTP, 0, 0)

> > >     If hInternetConnect Then

> > >         hFTPFileConnection = FtpFindFirstFile(hInternetConnect,
> > "test1.txt",
> > > sWFD, 0, 0)

> > >             If hFTPFileConnection <> 0 Then
> > >             bRet = FtpSetCurrentDirectory(hInternetConnect, "/") 'set
to
> > > root directory

> > >                 inputspec = "ftp://my.ftpsite.net/test2.txt"
> > >                 'inputspec = inputspec & sWFD.cFileName
> > >                 outputspec = "c:\txtfiles\test2.txt"
> > >                 'outputspec = outputspec & sWFD.cFileName
> > >                 Dim bRet2 As Boolean

> > >                 bRet2 = FtpGetFile(hInternetConnect, inputspec,
> > outputspec,
> > > True, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)
> > >                 bRet2 = FtpPutFile(hInternetConnect, outputspec,
> > inputspec,
> > > FTP_TRANSFER_TYPE_BINARY, 0)

> > >                     If bRet2 Then
> > >                         SendRequest = "ok"
> > >                     Else
> > >                         SendRequest = bRet2
> > >                     End If

> > >                 bRet = InternetCloseHandle(hFTPFileConnection)
> > >             End If
> > >         bRet = InternetCloseHandle(hInternetConnect)
> > >     End If
> > >     bRet = InternetCloseHandle(hInternetSession)

> > > End Function



Wed, 22 Sep 2004 07:57:59 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!
Ok, instead of saying it "doesn't work", let's say it's useless. By the
time your call to it executes, VB has almost always already called it
and cleared any error condition it may have held. Therefore when you
call it from your own code, you'll usually get back 0. Maybe you've
actually got a scenario where you can beat VB to it and get back the
actual code, but it's unpredictable, and with the next service pack, it
may quit working. Microsoft specifically added Err.LastDllError so that
there'd be a _reliable_ method for accessing the Windows error status.
If you want to rely on GetLastError(), hey, it's your code.


Quote:

> YES it does. it just it gets called, sometimes internally by vb itself when
> an api call is issued



> > GetLastError() doesn't work from VB. Use Err.LastDllError instead.



> > > Have you checked GetLastError() after the function calls?

> > > I personally would look at the following as well.

> > > You are using TRUE for Fail If Exist in the FtpGetFile, if the file
> exist,
> > > it will fail. No file transfer.  Thats why you need to see that
> > > GetLastError() result code when it fails.   Try changing that to TRUE
> and
> > > see if it works.

> > > Other than that, possible some incorrect prototype interface in the
> header
> > > file?

> > > ------



> > > > I have followed the MSDN instructions as much as I can (its written in
> > c++
> > > > and I'm trying to write it in vb).
> > > > The FTP root is wide open (no permissions necessary).  I also have
> read
> > > and
> > > > write permissions set on the home directory.
> > > > There are no permissions on the folder itself (everyone has full
> > control).
> > > > I also can get and put files using an FTP app (CuteFTP32).
> > > > I also have a .bas file with all the declared functions from
> wininet.dll

> > > > Public Function SendRequest(sUrl As String, sMethod As String, bSecure
> > As
> > > > Boolean) As String
> > > >   Dim hInternetSession As Long
> > > >   Dim hInternetConnect As Long
> > > >   Dim hFTPFileConnection As Long
> > > >   Dim bRet As Integer
> > > >   Dim sHeader As String
> > > >   Dim sWFD As WIN32_FIND_DATA

> > > >   ' default return is blank
> > > >   SendRequest = ""

> > > >   ' Initialize variables
> > > >   hInternetSession = 0
> > > >   hInternetConnect = 0
> > > >   hFTPFileConnection = 0

> > > >   hInternetSession = InternetOpen("Microsoft Internet Explorer",
> > > > INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)

> > > >   hInternetConnect = InternetConnect(hInternetSession,
> > > > "ftp://my.ftpsite.net", INTERNET_INVALID_PORT_NUMBER, vbNullString,
> > > > vbNullString, INTERNET_SERVICE_FTP, 0, 0)

> > > >     If hInternetConnect Then

> > > >         hFTPFileConnection = FtpFindFirstFile(hInternetConnect,
> > > "test1.txt",
> > > > sWFD, 0, 0)

> > > >             If hFTPFileConnection <> 0 Then
> > > >             bRet = FtpSetCurrentDirectory(hInternetConnect, "/") 'set
> to
> > > > root directory

> > > >                 inputspec = "ftp://my.ftpsite.net/test2.txt"
> > > >                 'inputspec = inputspec & sWFD.cFileName
> > > >                 outputspec = "c:\txtfiles\test2.txt"
> > > >                 'outputspec = outputspec & sWFD.cFileName
> > > >                 Dim bRet2 As Boolean

> > > >                 bRet2 = FtpGetFile(hInternetConnect, inputspec,
> > > outputspec,
> > > > True, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)
> > > >                 bRet2 = FtpPutFile(hInternetConnect, outputspec,
> > > inputspec,
> > > > FTP_TRANSFER_TYPE_BINARY, 0)

> > > >                     If bRet2 Then
> > > >                         SendRequest = "ok"
> > > >                     Else
> > > >                         SendRequest = bRet2
> > > >                     End If

> > > >                 bRet = InternetCloseHandle(hFTPFileConnection)
> > > >             End If
> > > >         bRet = InternetCloseHandle(hInternetConnect)
> > > >     End If
> > > >     bRet = InternetCloseHandle(hInternetSession)

> > > > End Function



Wed, 22 Sep 2004 11:43:54 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!
Oh, ok.  I don't program in VB.  I think the other guy got the point though,
if he is a VB programmer.

thanks for the input.


Quote:
> GetLastError() doesn't work from VB. Use Err.LastDllError instead.



> > Have you checked GetLastError() after the function calls?

> > I personally would look at the following as well.

> > You are using TRUE for Fail If Exist in the FtpGetFile, if the file
exist,
> > it will fail. No file transfer.  Thats why you need to see that
> > GetLastError() result code when it fails.   Try changing that to TRUE
and
> > see if it works.

> > Other than that, possible some incorrect prototype interface in the
header
> > file?

> > ------



> > > I have followed the MSDN instructions as much as I can (its written in
> c++
> > > and I'm trying to write it in vb).
> > > The FTP root is wide open (no permissions necessary).  I also have
read
> > and
> > > write permissions set on the home directory.
> > > There are no permissions on the folder itself (everyone has full
> control).
> > > I also can get and put files using an FTP app (CuteFTP32).
> > > I also have a .bas file with all the declared functions from
wininet.dll

> > > Public Function SendRequest(sUrl As String, sMethod As String, bSecure
> As
> > > Boolean) As String
> > >   Dim hInternetSession As Long
> > >   Dim hInternetConnect As Long
> > >   Dim hFTPFileConnection As Long
> > >   Dim bRet As Integer
> > >   Dim sHeader As String
> > >   Dim sWFD As WIN32_FIND_DATA

> > >   ' default return is blank
> > >   SendRequest = ""

> > >   ' Initialize variables
> > >   hInternetSession = 0
> > >   hInternetConnect = 0
> > >   hFTPFileConnection = 0

> > >   hInternetSession = InternetOpen("Microsoft Internet Explorer",
> > > INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)

> > >   hInternetConnect = InternetConnect(hInternetSession,
> > > "ftp://my.ftpsite.net", INTERNET_INVALID_PORT_NUMBER, vbNullString,
> > > vbNullString, INTERNET_SERVICE_FTP, 0, 0)

> > >     If hInternetConnect Then

> > >         hFTPFileConnection = FtpFindFirstFile(hInternetConnect,
> > "test1.txt",
> > > sWFD, 0, 0)

> > >             If hFTPFileConnection <> 0 Then
> > >             bRet = FtpSetCurrentDirectory(hInternetConnect, "/") 'set
to
> > > root directory

> > >                 inputspec = "ftp://my.ftpsite.net/test2.txt"
> > >                 'inputspec = inputspec & sWFD.cFileName
> > >                 outputspec = "c:\txtfiles\test2.txt"
> > >                 'outputspec = outputspec & sWFD.cFileName
> > >                 Dim bRet2 As Boolean

> > >                 bRet2 = FtpGetFile(hInternetConnect, inputspec,
> > outputspec,
> > > True, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)
> > >                 bRet2 = FtpPutFile(hInternetConnect, outputspec,
> > inputspec,
> > > FTP_TRANSFER_TYPE_BINARY, 0)

> > >                     If bRet2 Then
> > >                         SendRequest = "ok"
> > >                     Else
> > >                         SendRequest = bRet2
> > >                     End If

> > >                 bRet = InternetCloseHandle(hFTPFileConnection)
> > >             End If
> > >         bRet = InternetCloseHandle(hInternetConnect)
> > >     End If
> > >     bRet = InternetCloseHandle(hInternetSession)

> > > End Function



Wed, 22 Sep 2004 14:38:12 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!
A couple of things that I noticed right off the bat.  First, you don't
specify the ftp:// in the name of the site to which you're connecting in
the InternetConnect call.  Second, I don't like the
INTERNET_INVALID_PORT_NUMBER.  I believe that there is a constant that
defines the FTP port number (21, I believe but I'd verify that to be
sure).  Also, I don't think that the inputspec should include the
ftp://domain header.  Try passing just the file name instead.  

There might be more, but it's a start.

Bruce Johnson
TAG Consulting
http://www.tagconsulting.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Thu, 23 Sep 2004 01:28:49 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!
Yes I tried both and GetLastError() did just return 0 (after adding a call
to GetCurrentProcess(), w/o this call I got null or empty string)

The called Err.LastDllError is returning 12003 and Err.ErrorDescription is
returning
200 Type set to I.
200 PORT command successful.
550 ftp://my.ftpsite.com/myfile.txt The filename, directory name, or volume
label syntax is incorrect.
550 ftp://my.ftpsite.com/myfile.txt The filename, directory name, or volume
label syntax is incorrect.

I don't know why its printing the last line twice and it has to be a bogus
error, because I am 100% sure the file exists, I'm sure the ftp service is
running, I even opened up the permissions so "everyone" can read and write
to the directory, as well as open permissions in IIS.
At least now I know its not my code and something wrong with IIS.
If I enter 550 ftp://my.ftpsite.com/myfile.txt  into a browser, for some
reason it won't open the file and display the contents, but if I browse to
the root, I can see the txt file, and can drag it on my desktop, but once I
double click to open it, I get an error saying the page cannot be displayed.
But once I copy the file into the www root, I can open it up and see
everything, further proof IIS is messed up.

Thanks for the everyones help.
gv

I would of posted earlier but DSL is as reliable as they say!


Quote:
> Ok, instead of saying it "doesn't work", let's say it's useless. By the
> time your call to it executes, VB has almost always already called it
> and cleared any error condition it may have held. Therefore when you
> call it from your own code, you'll usually get back 0. Maybe you've
> actually got a scenario where you can beat VB to it and get back the
> actual code, but it's unpredictable, and with the next service pack, it
> may quit working. Microsoft specifically added Err.LastDllError so that
> there'd be a _reliable_ method for accessing the Windows error status.
> If you want to rely on GetLastError(), hey, it's your code.



> > YES it does. it just it gets called, sometimes internally by vb itself
when
> > an api call is issued



> > > GetLastError() doesn't work from VB. Use Err.LastDllError instead.



> > > > Have you checked GetLastError() after the function calls?

> > > > I personally would look at the following as well.

> > > > You are using TRUE for Fail If Exist in the FtpGetFile, if the file
> > exist,
> > > > it will fail. No file transfer.  Thats why you need to see that
> > > > GetLastError() result code when it fails.   Try changing that to
TRUE
> > and
> > > > see if it works.

> > > > Other than that, possible some incorrect prototype interface in the
> > header
> > > > file?

> > > > ------



> > > > > I have followed the MSDN instructions as much as I can (its
written in
> > > c++
> > > > > and I'm trying to write it in vb).
> > > > > The FTP root is wide open (no permissions necessary).  I also have
> > read
> > > > and
> > > > > write permissions set on the home directory.
> > > > > There are no permissions on the folder itself (everyone has full
> > > control).
> > > > > I also can get and put files using an FTP app (CuteFTP32).
> > > > > I also have a .bas file with all the declared functions from
> > wininet.dll

> > > > > Public Function SendRequest(sUrl As String, sMethod As String,
bSecure
> > > As
> > > > > Boolean) As String
> > > > >   Dim hInternetSession As Long
> > > > >   Dim hInternetConnect As Long
> > > > >   Dim hFTPFileConnection As Long
> > > > >   Dim bRet As Integer
> > > > >   Dim sHeader As String
> > > > >   Dim sWFD As WIN32_FIND_DATA

> > > > >   ' default return is blank
> > > > >   SendRequest = ""

> > > > >   ' Initialize variables
> > > > >   hInternetSession = 0
> > > > >   hInternetConnect = 0
> > > > >   hFTPFileConnection = 0

> > > > >   hInternetSession = InternetOpen("Microsoft Internet Explorer",
> > > > > INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)

> > > > >   hInternetConnect = InternetConnect(hInternetSession,
> > > > > "ftp://my.ftpsite.net", INTERNET_INVALID_PORT_NUMBER,
vbNullString,
> > > > > vbNullString, INTERNET_SERVICE_FTP, 0, 0)

> > > > >     If hInternetConnect Then

> > > > >         hFTPFileConnection = FtpFindFirstFile(hInternetConnect,
> > > > "test1.txt",
> > > > > sWFD, 0, 0)

> > > > >             If hFTPFileConnection <> 0 Then
> > > > >             bRet = FtpSetCurrentDirectory(hInternetConnect, "/")
'set
> > to
> > > > > root directory

> > > > >                 inputspec = "ftp://my.ftpsite.net/test2.txt"
> > > > >                 'inputspec = inputspec & sWFD.cFileName
> > > > >                 outputspec = "c:\txtfiles\test2.txt"
> > > > >                 'outputspec = outputspec & sWFD.cFileName
> > > > >                 Dim bRet2 As Boolean

> > > > >                 bRet2 = FtpGetFile(hInternetConnect, inputspec,
> > > > outputspec,
> > > > > True, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0)
> > > > >                 bRet2 = FtpPutFile(hInternetConnect, outputspec,
> > > > inputspec,
> > > > > FTP_TRANSFER_TYPE_BINARY, 0)

> > > > >                     If bRet2 Then
> > > > >                         SendRequest = "ok"
> > > > >                     Else
> > > > >                         SendRequest = bRet2
> > > > >                     End If

> > > > >                 bRet = InternetCloseHandle(hFTPFileConnection)
> > > > >             End If
> > > > >         bRet = InternetCloseHandle(hInternetConnect)
> > > > >     End If
> > > > >     bRet = InternetCloseHandle(hInternetSession)

> > > > > End Function



Sun, 26 Sep 2004 03:11:16 GMT  
 FtpGetFile and FtpPutFile returns false - Please help!


Hello gv,

Quote:
> Yes I tried both and GetLastError() did just return 0 (after adding a call
> to GetCurrentProcess(), w/o this call I got null or empty string)

> The called Err.LastDllError is returning 12003 and Err.ErrorDescription is
> returning
> 200 Type set to I.
> 200 PORT command successful.
> 550 ftp://my.ftpsite.com/myfile.txt The filename, directory name, or
volume
> label syntax is incorrect.
> 550 ftp://my.ftpsite.com/myfile.txt The filename, directory name, or
volume
> label syntax is incorrect.

> I don't know why its printing the last line twice and it has to be a bogus
> error, because I am 100% sure the file exists,

Nope, it's not a bogus error.  The file may well exist, but you're not
asking for it.

[a small part of your code]
  hInternetConnect = InternetConnect(hInternetSession, _
        "ftp://my.ftpsite.net", INTERNET_INVALID_PORT_NUMBER, _
        vbNullString, vbNullString, INTERNET_SERVICE_FTP, 0, 0)

In the above you're  requesting  FTP-service *twice*.  Once by the prefix
"ftp://" on the Server-name, and once with "INTERNET_SERVICE_FTP".   It
think you should get rid of the first one (only using the server-name).

By the way, should the INTERNET_INVALID_PORT_NUMBER in the above not be
INTERNET_DEFAULT_FTP_PORT ?

[another (very) small part of your code]
      inputspec = "ftp://my.ftpsite.net/test2.txt"

The above should hold the Path & filename to the file you want, not the
Protocol and the Server-name too.  I think it should be something like
"/test2.txt".

Quote:
> I'm sure the ftp service is
> running, I even opened up the permissions so "everyone" can read and write
> to the directory, as well as open permissions in IIS.
> At least now I know its not my code and something wrong with IIS.

Don't be too sure about that.  I just fished two serious (interpretation)
errors outof your program, and did not even looked at it right. (that means
there could be more ...)

Quote:
> If I enter 550 ftp://my.ftpsite.com/myfile.txt  into a browser, for some
> reason it won't open the file and display the contents, but if I browse to
> the root, I can see the txt file, and can drag it on my desktop, but once
I
> double click to open it, I get an error saying the page cannot be
displayed.
> But once I copy the file into the www root, I can open it up and see
> everything, further proof IIS is messed up.

I do not know why you've got problems with the file in one directory, and
none in another (I take it both directories are on the Server).  My guess is
that there are some permissions set somewhere that are troubeling you.

Regards,
  Rudy Wieser



Sun, 26 Sep 2004 04:06:12 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. FtpGetFile and FtpPutFile returns false - Please help!

2. WinInet and FtpGetFile() FtpPutFile() (Large Numbers of Files)

3. FtpPutFile and FtpGetFile progress

4. ftpgetfile and ftpputfile

5. FtpPutFile and FtpGetFile progress

6. WinInet and FtpGetFile() FtpPutFile() (Large Numbers of Files)

7. ftpgetfile and ftpputfile

8. FTPPutFile and FTPGetFile

9. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

10. Shiftn returning false -- Why?

11. VB.NET - isdebug always returns false

12. eof() always returning false - Beta 2

 

 
Powered by phpBB® Forum Software