Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP Get not working ?

Status
Not open for further replies.

cbsm

Programmer
Oct 3, 2002
229
FR
Hi,

I need to copy to and from an ftp server - from Access.
I checked the site and found some helpfull posts.
So, I added and Inet control to a form and used the following code (sorry I do not remember from whom I took it).

Private Sub Command0_Click()
SetUpftp
DownloadFile
End Sub


Private Sub SetUpftp()

Inet1.AccessType = icUseDefault
Inet1.URL = "ftp://" & IPAddress & "/"
Inet1.UserName = "user"
Inet1.Password = "Password"
Inet1.RequestTimeout = 40
End Sub

Private Sub DownloadFile()

Dim lStr_ServPathName As String
Dim lStr_NewPathName As String
Dim lStr_ftpCommand As String
Dim lStr_ftpComment As String

lStr_ServPathName = "\folder1\fileToGet.txt"
lStr_NewPathName = "c:\fileToGet.txt"

lStr_ftpComment = "GET " & lStr_ServPathName & " " & lStr_NewPathName

ExecuteftpCommand lStr_ftpCommand

End Sub

Private Sub ExecuteftpCommand(rStr_ftpCommand As String)

On Error Resume Next

Inet1.Execute , rStr_ftpCommand
While Inet1.StillExecuting
DoEvents
Wend

End Sub


Private Sub Inet1_StateChanged(ByVal rInt_ftpState As Integer)

Dim lStr_ErrorMsg As String

Select Case rInt_ftpState
Case icError
lStr_ErrorMsg = "Code: " & Inet1.ResponseCode & " : " & Inet1.ResponseInfo
MsgBox lStr_ErrorMsg
'Inet1.Cancel

Case icResponseCompleted
MsgBox "ftp Operation Complete"

Case icNone
Case icResolvingHost
Case icHostResolved
Case icConnecting
Case icConnected
Case icRequesting
Case icRequestSent
Case icReceivingResponse
Case icResponseReceived
Case icDisconnecting
Case icDisconnected
End Select

End Sub


Result : No error message, but the file (fileToGet.txt) does not appear on my C:\ drive !
(Message "ftp Operation Complete" appears).
I tried it the other way around, with the "PUT" command - with no success either !
What am I doing wrong ?

Thank you !
 
Try using forward slashes:
[tt]
lStr_ServPathName = "/folder1/fileToGet.txt"
lStr_NewPathName = "c:\fileToGet.txt"
[/tt]
If that doesn't work, try without the first slash:
[tt]
lStr_ServPathName = "folder1/fileToGet.txt"
lStr_NewPathName = "c:\fileToGet.txt"
[/tt]
 
Thank you - but still not working ...
I tried with back and forward slashes.
with and without the first one.
I Xple checked that the file really exists and name OK.
I do not know if this can help but I added
MsgBox Inet1.ResponseInfo
Just after "MsgBox "ftp Operation Complete" " and it says "There are not more files.".
I have this is something really stupid - but I am getting crazy !
To make sure I am doing things right :
The file on the server is on IPAdress\folder1\fileToGet.txt - and I'd like to copy this file on my c:\ drive.
Thanks,
 

Can you get it manually?

Windows: Start/Run type
[tt]
FTP Servername
[/tt]
and press enter. Then follow the prompts to enter your ID and password. Then try some commands.
[tt]
dir
[/tt]
to get a list of folders.
[tt]
cd FolderName
[/tt]
to change directory
[tt]
get FileName c:\fileToGet.txt
[/tt]
to retrieve the file.

If you can't do it manually, you probably won't be able to do it with a program. If you can do it manually, then recreate the steps with program code.

btw, the folder names and file names might be case-sensitive. (The commands are not)

 
Thank you Zathras,

I was able to get the file manually, but still no succes through code.
What I don't understand, is that I don't get any error message!
I suppose it is something really stupid, like a case problem, or back-forward slash or something like that.
But I wrote those lines in so many different ways now !
Is there a way I could see if it's not finding the file, or if there are rights problem, or something else ?

In fact I tried for example :
lStr_NewPathName = "c:\fileToGet.txt"

lStr_ServPathName = "\folder1\fileToGet.txt"
or
lStr_ServPathName = "folder1\fileToGet.txt"
or
lStr_ServPathName = "\fileToGet.txt"
or
lStr_ServPathName = "fileToGet.txt"


lStr_ftpComment = "GET " & lStr_ServPathName & " " & lStr_NewPathName


Always the same result ! (which is no copying of the files, but no error message what so ever).
 

Did you try
[tt]
cd folder1
get fileToGet.txt c:\fileToGet.txt
[/tt]
?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top