Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Ftpgetfile


Hello,
I am developing a FTP program to get some files from FTP server.
I am using FTPGETFILE this API and it works fine. When doing the testing, i try to disable the connection (unplug the network cable) but this API doesnt return and hang... Can anyone know how to solve this problem?
I am using window 98 for developemnt and i found this API return in window XP..

Thomas




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
FTP Using FTPGetFile
I am writing a VB 6.0 program that is using Wininet api to perform FTP functions. Iím connecting to an FTP site that first requires a firewall id and password then a site id and password.

Iíve set it up to first perform InternetOpen then InternetConnect twice Ė first against with the firewall id/password and then with the site id/password. These operations seem to work correctly. When I attempt a FTPGetFile I receive a 12003 error Ė Internet Extended Error.

Because Iíve used the InternetConnect twice I have two session ids. Iíve tried the FTPGetFile with both of them but receive the same error. The file Iím trying to download is a zip file.

I'm thinking the problem is the firewall because when I try the process within the firewall (using only 1 InternetConnect) it works. Am I handling the firewall correctly or do I have to combine the 2 InternetConnectís? If so, how?

Thanks in advance,
Rich

FtpGetFile Api
Hello all
Is it possible to build a progress bar to show the progress of the download?
I use the FtpGetFile api in vb6.

Ftpgetfile SIZE
I am wanting to know if there is a way to disable the size command when using get file.
EXAMPLE .
"PORT 127,0,0,1,4,135
SIZE CURRENT
RETR CURRENT
Data session connected with client (Port)"
above is what appears on the ftp-server when passing the command using the wininet.dll getfile with my visual basic program.

when I go to the Command prompt and do a get file the ftp-server does not have the SIZE. thanks

FtpGetFile Extd Err
I use a very typical sample VB program downloaded from website using FTP WinInet APIs (but not Microsoft Inet control, for Inet control can not transfer the Ascii text file by executing "GET" command, only the binary) transfer files from/to remote mainframe server.

And I am stuck with this function: FtpGetFile for the following error messages: (this function always return false)

rcd Extd Err: 0 550 CWD cmd failed: EDC5129I No such file or directory.

then:
FtpGetFile Err: 0 200 Representation type is Ascii NonPrint
227 Entering Passive Mode(159,83,73,4,7,223)
501 command aborted --FTP server not configured for SIZE
550 Name length error for pathname 01 1 15 VB 255 6233 PS SYSTC.MYTEST.DATA

I am wondering if I need to figure out the configuration in our FTP server for the file SIZE particularly, for each listed file in the remote server, I don't see the size being specified, except the file name, file type, date modified, size column always show blank, is this cause the problem?

Thank you for any input!

FTPGetFile Problem
I'm using the FTPGetFile function to try and download a file from an FTP server onto the local machine running my app.

The function calls all goes swimmingly well, no errors, and even creates the right file in the right place on the local machine!
However, the file it creates is zero length! There is no data in it!! (The original on the FTP host definately does!)

This is the code im using:

----------------------------------------------
If hInetConn Then

'If we've been given a remote
'path then change to it
If sFilePath <> "" Then

ChangeDir (sFilePath)

End If

'Add a "" to the local path if it needs it
If sDownloadPath <> "" Then
sNewFile = MakeDOSDir(sDownloadPath) & sFilename
Else
sNewFile = sFilename
End If


'Download the file
If FtpGetFile(hInetConn, _
sFilename, _
sNewFile, _
False, _
FILE_ATTRIBUTE_ARCHIVE, _
FTP_TRANSFER_TYPE_UNKNOWN, _
0&) Then

GetFile = True

Else

'Log the error
LogError (GetFTPErr(Err.LastDllError))
GetFile = False

End If 'If FtpGetFile


End If

----------------------------------------------

This code is part of a function (GetFile) that receives as its arguments:

sFilename - the filename to download
sFilePath - the remote path on the FTP server (optional)
sDownloadPath - the local dir to download to (optional)

Like I said, no errors occur and it gives the appearance of having worked OK - until the file size is checked!!! Anyone got any ideas???

Thanks

FtpGetFile - PROBLEM
I had some files residing in a remote server. A dll had been done to retrieve a file from the remote server.
The naming conventions of the files are abcnn.yy where nn and yy are not fixed. Only abc is fixed. I need to copy the files from the remote server where the exact filenames are not known due to nn and yy.

The dll can get file by specifying the remote filename currently by calling the dll and passing the parameters as


Remote server IP address,'c: est est.txt','/test ext.txt',username,password


Can I specify the remote filename as /testabc*.* so I can get whatever file that is residing at the server. The file retrieve from the server to local workstation will follow the remote server filename.

all vb experts .........PLs help........ emergency...............

live - threatening



below is my clsFtpGet (ActiveX DLL project type)


Public Function FtpGetApi(IPAddress As String, LocalFile As String, RemoteFile As String, UserName As String, Password As String) As String

Dim lngINet As Long
Dim lngInetConn As Long
Dim intError As Integer
Dim pingres As String
Dim errpos As Byte
On Error GoTo err1

' Open an internet session (without proxy)
' To connect through a proxy 2nd parameter = 3

errpos = 0

lngINet = InternetOpen("Billing Computer System", 1, vbNullString, vbNullString, 0)

' After creating the session connect to the server

If lngINet = 0 Then
'Cannot Connect to Internet
ftpGetError = "Cannot Connect to Internet"
FtpGetApi = "N"
Exit Function
End If

errpos = 1 ' denoting session created

lngInetConn = InternetConnect(lngINet, IPAddress, 0, UserName, Password, 1, 0, 0)

If lngInetConn = 0 Then
'Cannot Connect to Server
ftpGetError = "Cannot Connect to Server"
FtpGetApi = "N"
' close the handle before exiting
InternetCloseHandle lngINet
MsgBox ("Cannot Connect to Server")
Exit Function
End If

errpos = 2 ' denoting server connected

' After establishing the connection send the file
' 4th parameter - 1 - Ascii file transfer
' - 2 - Binary file trasnfer

FileSchedule = ""
FileRecd = ""

If FtpGetFile(lngInetConn, RemoteFile, LocalFile, 0, 0, 1, 0) Then
FtpGetApi = "Y"
Else
FtpGetApi = "N"
End If

If FtpGetApi = "N" Then
ftpGetError = "File is not able to be retrieve"
End If

errpos = 3 ' denoting err while sending

' Close the handles created

InternetCloseHandle lngInetConn
InternetCloseHandle lngINet

errpos = 4 'No errors
'no action
' sending status is true always even if file not sent
Exit Function

err1:

Debug.Print "Error : " & Err.Number & " " & Err.Description

'close the handles created above incase they are not closed
Select Case errpos
Case 1
InternetCloseHandle lngINet
Case 2
InternetCloseHandle lngInetConn
InternetCloseHandle lngINet
End Select

End Function

FtpGetFile And GetLastError
Hi!!

I'm using FtpGetFile api and it returns me false even if there are no bad conditions.
I wanted to add GetLastError to know why it gives me that false, but I don't understand how I have to use it.

In msds site I read that GetLastError returns the value set with the SetLastError, but I can't set the error!

How do I have to do??

thank you

FTPGetFile And Freezing
I have my app built and it works great, but I do not like the fact that when it hands control over to the DLL to get the file from the server using FTPGetFile the app looks frozen. I have seen other posts on this, but no resolution.

Does anyone out there have any ideas? Someone said to use an OCX instead of a DLL but I don't really understand this. Anyone have the same problem and got a better solution?

Thanks in advance.

FtpGetFile Question
Hi,

Using the following API, does anyone know how many bytes at a time this function will retrieve, or does it just download the entire file???


VB Code:
Private Declare Function FtpGetFile Lib "wininet.dll" _    Alias "FtpGetFileA" _    (ByVal hOutboundSession&, _    ByVal lpszRemoteFile$, _    ByVal lpszNewFile$, _    ByVal fFailIfExists As Boolean, _    ByVal dwFlagsAndAttributes&, _    ByVal dwFlags&, _    ByVal dwContext&) As Boolean


I'm asking this because I've created an ftp program which our customer uses to download files that another company sends it regularly. We had a problem for the first time yesterday in that 2 files were not complete.

Currently, we think that the problem is not in our software and that the problem lies with the company that sent the files. Up to now, I thought that if a file was not successfully downloaded completely, that no file would appear in the local directory, but now I am not sure anymore. Does anyone know?????

Thanks for any help, I appreciate it!

FtpGetFile - GetLastError
Hi,

I have successfully used FtpGetFile but I also need to test exceptions. I ran another test to Get a m/f file and FTP it to my c: emp directory. I set fFailIfExists to TRUE and ran another test. I made sure I already had a file in the directory so the Get would fail.

I received a return code of FALSE as expected. I then called GetLastError to try to get a specific error code. It returned 0.

I would like to be able to send a return code or display an error message saying something like "File already exists - Get failed".

Since GetLastError doesn't seem to work is there any way to get a specific error message or am I doing something wrong. My code for the GetLastError is:

Dim ErrorCode As Integer
ErrorCode = GetLastError()

Thanks,

Jim

FTP - Pb TimeOUt With API FtpGetFile
HEllo all!

I have big trouble with the DLL Wininet.dll. My pb is :
If the FTP server disconnect me when i try to retrieve a file from its, the API used (FtpGetFile) doesn't stop and loop =&gt; and i need to kill my soft with taskman
i try to put an API Timer with a CreateThread / TerminateThread but, FtpGetFile stills runs, despite the end of the thread's container ?!?
i try this and it doesn't work

' event Sub call by Windows for a Timer
public Sub TimerProc(byval hwnd as Long, byval uMsg as Long, byval idEvent as Long, _
byval dwTime as Long)

iComp = iComp + 1
Debug.print "Compteur : " & iComp & " / 3"
If iComp &gt; 3 then
' close the last thread
Debug.print "Transfert Stopped"
KillTimer Form1.hwnd, 0
CloseHandle hThread
TerminateThread hThread, 0
End If
Exit Sub
End Sub

' Sub call by a CreateThread
public Sub AsyncThread()

Dim lngTimerID as Long

iComp = 0
lngTimerID = SetTimer(Form1.hwnd, 0, 1000, AddressOf TimerProc)

Debug.print "Connexion : " & mlConnection & "FileOrig : " & sServerFileAndPath & "FileDest: " & sDestinationFileAndPath
If FtpGetFile(mlConnection, sServerFileAndPath, sDestinationFileAndPath, false, INTERNET_FLAG_RELOAD, FTP_TRANSFER_TYPE_ASCII, 0) = false then
Debug.print "Bad luck for u"
End If

KillTimer Form1.hwnd, 0

End Sub




Plz help me! thx

Trouble With FTPGetFile From Unix
I am using the wininet API to get files (ftp) to my local machine.

The remote machine is Unix, and when the file is received and i open it with notepad, i get all linefeeds are gone, and a square sign is put where the crlf should be.

i have tried changing between binary and ascii transfer mode.

Anyone have a suggestion on how to fix this? either by FTP'ing it correctly or by opening it and resaving it?



Andras Eliassen - Microsoft Certified Professional
I have just started a blog about vb.net, oracle, mysql tips etc.
http://www.EasyWebBasket.net
Welcome to visit and leave comments ;)


Regards,
Botzy

FTPGetFile For Pocket PC 2002
helo... i having problem in doing FTP... so do anyone can help me... the error code is Error 87 while running the FTP PutFile
The source code is from Microsoft website but i still having problem on it

Use Wildcards With FtpGetFile (of Wininet.dll)
Can you tell me how can I get multiple files using FtpGetFile?. I only can get one file with this command. I thanks to everybody that send me an example code.
Tanks to everybody.

FeReNZCy

FTPGetfile API Hangs/waits A Long Time To Release After Downloading Large Files
Does anyone know why ftpgetfile hangs and waits for a about a hour before it returns.. this error only occurs when I am downloading large file eg:>200mb..
I enumerate a folder get all files and the use ftpgetfile to get them all.. this part works but I will be dammed if I can figure out why on large files it hangs.. the FTP server I am using is MS 2003 sp1 it used to work..
I have done some testing and instead of using ftpgetfile I started using InternetReadFile() and that worked for large files but for some reason I cant get to to download all files in a directory only the first one and then it errors out :-(

any suggestion would be appreciated.

Copyright © 2005-08 www.BigResource.com, All rights reserved