Re: Permission Denied After Calling ListDir - WeOnlyDo Discussion board

Re: Permission Denied After Calling ListDir (General questions)

by Roy, Tuesday, March 08, 2005, 21:30 (6986 days ago) @ wodSupport

Here is some of the pertinent code...

'Connecting to Server...

Private Sub Command1_Click()

FTP1.Blocking = True
FTP1.Protocol = FTPSwithdata

On Error GoTo ErrorHandler
FTP1.Connect

Text1.Text = Connected
Exit Sub

ErrorHandler:

If Err.Number <> 0 Then 'Succes
msgbox Connected
End If

End Sub

'Looking for Remote Directory, Creating if it doesn't exist

Private Function CheckSwitchRemoteDir()

On Error Resume Next

If bConnected Then

FTP1.CheckDir CustomerJobsSomeSubFolder 'Root Directory = CustomerJobs

If Err.Number = 40550 Then 'Directory Does Not Exist
CheckSwitchRemoteDir = False
FTP1.MakeDir CustomerJobsSomeSubFolder

If FTP1.RemotePath = CustomerJobsSomeSubFolder Then
CheckSwitchRemoteDir = True
Else
CheckSwitchRemoteDir = False
End If

ElseIf Err.Number = 0 Then 'Directory Exist
CheckSwitchRemoteDir = True
End If

End If

End Sub

'Listing Directory

Private Sub Command3_Click()
FTP1.ListDir
End Sub

'Removing Directory
Private Sub Command6_Click()
FTP1.RemoveDir CustomerJobsSomeSubFolder
End Sub

'Adding Folder Contents to Text1.text
Private Sub FTP1_Done(ByVal ErrorCode As Long, ByVal ErrorText As String)

Dim iLoop As Integer

'Some logic to make sure this only runs after ListDir...

If bListDir then
If FTP1.DirItems.Count > 0 Then

For iLoop = 0 To FTP1.DirItems.Count - 1
Text4.Text = Text4.Text & FTP1.DirItems(iLoop).name & vbCrLf
Next iLoop

End If
End If

End Sub

'*********************************************************
I have tried with Blocking on and off...

I have tried FTP1.Abort in between ListDir and RemoveDir...

I have also tried the same process in an off the shelf FTP client (CuteFTP Pro) and it works fine. Problem doesn't appear to be the server...

I only seem to get this error after I call ListDir...


Complete thread: