|
-
Jan 10th, 2007, 06:02 PM
#1
Thread Starter
Fanatic Member
Ftp Help Required App looks like its frozen
Hi guys i got the following code for ftp download problem i have is its like the app is frozen for the duration of the download i checked in task manager and pc also thinks its not repsponding this corrects when download finishes. its usually for a second or so on 3 mb files but the bigger the file the longer the freeze pc still works fine all the time this is happening its the app that is non reponsive. i dont understand this code as well as i could and i cant seem to fix it. any help would be great
VB Code:
Private Sub downloadFile_Click()
Dim i As Long
On Error Resume Next
For i = 0 To List2.ListCount - 1
'Check if file has been selected
If List2.Selected(i) = True Then
Call FtpGetFile(hConnection, sFile.Text, App.Path & "\" & sFile.Text, 0, 0, 2, 0)
DoEvents
End If
Next
End Sub
Sub DownloadFiles(ftp_url As String, username As String, password As String)
Dim sOrgPath As String
'open an internet connection
hOpen = InternetOpen("API-Guide sample program", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
'connect to the FTP server
hConnection = InternetConnect(hOpen, ftp_url, INTERNET_DEFAULT_FTP_PORT, username, password, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
sOrgPath = String(MAX_PATH, 0) 'create a buffer to store the original directory
FtpGetCurrentDirectory hConnection, sOrgPath, Len(sOrgPath) 'get the directory
FtpSetCurrentDirectory hConnection, "/jd/logs/" 'set the current directory to 'root/httpdocs'
EnumFiles hConnection 'enumerate the file list from the current directory ('root/testing')
End Sub
Private Sub ftpconnect_Click()
If ftpconnect.Caption = "Connect" Then
Screen.MousePointer = vbHourglass
DownloadFiles txtFTP, txtUserName, txtPassword
Screen.MousePointer = vbDefault
ftpconnect.Caption = "Disconnect"
Else
If ftpconnect.Caption = "Disconnect" Then
InternetCloseHandle hConnection
InternetCloseHandle hOpen
List2.Clear
ftpconnect.Caption = "Connect"
End If
End If
End Sub
thanks in advance
-
Jan 11th, 2007, 05:13 PM
#2
Thread Starter
Fanatic Member
Re: Ftp Help Required App looks like its frozen
Hi guys also in looking at this code how could it be moded to resume a dl rather than dl complete file? thanks again
-
Jan 12th, 2007, 02:39 AM
#3
Frenzied Member
Re: Ftp Help Required App looks like its frozen
an Application Freeze usually happens when it encounters a line of code that takes much time for execution. There are various ways of getting rid of this. Try to check the codebank for some sources.
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Jan 12th, 2007, 02:50 AM
#4
Re: Ftp Help Required App looks like its frozen
Correct! Besides there could be a timed out or probably the size is big for downloading. Have you tried downloading text files only?
-
Jan 14th, 2007, 02:57 PM
#5
Thread Starter
Fanatic Member
Re: Ftp Help Required App looks like its frozen
-
Jan 14th, 2007, 03:16 PM
#6
Re: Ftp Help Required App looks like its frozen
The Inet APIs (which I assume is what you're using) will appear to "freeze" your app when they're doing something, like downloading a file. I'm not aware of any way around this other than executing the functions in another thread.
This is why I personally use the Winsock control instead. But that will add another dependency to your project.
-
Jan 17th, 2007, 08:27 AM
#7
Thread Starter
Fanatic Member
Re: Ftp Help Required App looks like its frozen
Thanks digi rev for the reply i wish i could change to that now but i didnt write this codes as i am fairly new to vb and i dont think i could mod it to use winsock instead
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|