Problem with error catching
Hi all... me again!!
I am having trouble catching (or ignoring!) an error... Thsi is my code
Code:
'GET THE NEWS ROUTINE
Private Sub getnews()
On Error GoTo UploadError
Inet1.AccessType = icUseDefault
Inet1.URL = myftp
Inet1.UserName = myusername
Inet1.Password = mypassword
Inet1.RequestTimeout = 40
MsgBox "before kill"
Kill "c:\news.mp3" ' DELETE FILE BEFORE UPLOAD
MsgBox "before get"
Inet1.Execute , "get " & FileName & " " & destinationfolder & " " & FileName ' D/L FILE
MsgBox "after get"
Do While Inet1.StillExecuting
DoEvents
Loop
Inet1.Execute , "CLOSE" ' CLOSE FTP CONNECTION
UploadError:
err_defined = "no"
If Err.Number = "0" Then serverresult = "File downloaded correctly"
If Err.Number = "35754" Then serverresult = "Unable to upload file, check password"
If Err.Number = "35764" Then MsgBox "Server busy, please wait", , "Server Message"
If Err.Number = "35752" Then MsgBox "Server Configuration Error, Check Config file", , "Server Message"
If Err.Number = "12014" Then Beep
End Sub
So... my problem is that I want to ignore the file that is trying to be deleted if it does not exist, but I DO want to detect errors on the FTP part. There is celarly a conflict here as the on error line detects there is no file for the kill command and jumps stright to the upload errors ignoring the FTP get...
Help?
Re: Problem with error catching
sorry, solved it, wasnt thinking !
Code:
'GET THE NEWS ROUTINE
Private Sub getnews()
On Error Resume Next
Kill "c:\news.mp3" ' DELETE FILE BEFORE UPLOAD
On Error GoTo UploadError
Inet1.AccessType = icUseDefault
Inet1.URL = myftp
Inet1.UserName = myusername
Inet1.Password = mypassword
Inet1.RequestTimeout = 40
MsgBox "before kill"
MsgBox "before get"
Inet1.Execute , "get " & FileName & " " & destinationfolder & " " & FileName ' D/L FILE
MsgBox "after get"
Do While Inet1.StillExecuting
DoEvents
Loop
Inet1.Execute , "CLOSE" ' CLOSE FTP CONNECTION
UploadError:
err_defined = "no"
If Err.Number = "0" Then serverresult = "File downloaded correctly"
If Err.Number = "53" Then MsgBox "Fiel error"
If Err.Number = "35754" Then serverresult = "Unable to upload file, check password"
If Err.Number = "35764" Then MsgBox "Server busy, please wait", , "Server Message"
If Err.Number = "35752" Then MsgBox "Server Configuration Error, Check Config file", , "Server Message"
If Err.Number = "12014" Then Beep
End Sub
Re: Problem with error catching
or better still to avoid the error by checking if the file exists first
if len(dir("c:\news.mp3")) > 0 then Kill "c:\news.mp3"
if you still get an error from the kill, it should not be ignored, as it may mean the file is open or something
Re: Problem with error catching
now you metnion it, the file being open is a possibility, and could be a problem, i'll try your suggestion, thanks!