How, exactly DO I use getAttributes to work out if (General questions)
Hi,
Checking for the existence of a directory (or, indeed, a file).
I know the client gets a 30018 error and that this goes to the 'Done' event, but what _actually_ recieves this error? What can I query, in my IF statement, to determine that the result was a null directory? A code example would be nice, since I cannot seem to find one.
Re: How, exactly DO I use getAttributes to work ou
Hi Daniel,
I assume you are using Blocking mode. In that case, you can simply ignore exceptions in your code, and check LastError immediately after the method executes.
I.e:
[code]On Error Resume Next
wodSftp1.RealPath( / )
if wodSftp1.LastError = 0 then
'Do something
else
'do something else
End if[/code]
Can you try something like that?
Regards,
Damba
Re: How, exactly DO I use getAttributes to work ou
Nice work, thanks. I'll give it a shot. LastError = 0 equates to success, I take it?
Re: How, exactly DO I use getAttributes to work ou
Daniel,
Yes. When 0 is indicated for error, that means that there was none, and method executed correctly.
Regards,
Damba
Re: How, exactly DO I use getAttributes to work ou
Okay. great. In fact, since it's a utility method I can just return the result from wodSftp1.LastError = 0 ... except Visual Studio is now complaining that operator '=' is not defined for system exceptions.
Re: How, exactly DO I use getAttributes to work ou
Daniel,
You're using wodSFTP.Net or wodSFTP?
If you're using .Net, why don't you simply try using try...catch statements to catch exception on certain method?
Regards,
Damba
Re: How, exactly DO I use getAttributes to work ou
Ah, right. Something like:
Try
wodSFTP.RemotePath = strDirectory
Return True
Catch
Return False
End Try
I suppose it's just that deliberately testing for failure, and then working forwards from an assumption as to why it failed, seems a bit counter-intuitive, but I guess there's only so much information that can be gained from looking down a secure pipe, and trying to interpret the messages that come back.
Re: How, exactly DO I use getAttributes to work ou
Daniel,
Please note that setting RemotePath will never cause an exception. RemotePath doesn't send anything to server, but only sets property.
You need to actually call a method in order to send something to server.
As for errors/exception handling, any of these should work:
[code] Try
sftp1.ListDir( /home/weonlydo/ )
Catch ex As Exception
'An error occured, do something
End Try
Or:
On Error Resume Next
sftp1.ListDir( /home/weonlydo )
If sftp1.LastError.Message <> Nothing Then
'...
End If[/code]
Hope I helped.
regards,
Damba