Notifications
Clear all

[Closed] Check FTP login

hello guys

I’m connecting to a FTP with maxscript and it works fine. I now want to secure the script if the username is wrong instead of maxscript throwing an error. How can I do?

Here’s my script

fn ConnectToFTP Login Password =
(
local webClient = dotnetObject “System.Net.WebClient”
local FTP_URL = @“ftp://test/

webClient.Credentials = dotnetObject “System.Net.NetworkCredential” Login Password
theUri=dotnetObject “System.Uri” (FTP_URL)
)

If I put a wrong login or password maxscript throws me an error; i’d like to try and catch it myself but I dont know how. I tried something like this:
if theUri == undefined then… but it doesnt work.

Help please!
thank you!!

3 Replies

wrapping it with try catch may help

if ( try ( ConnectToFTP login pass ) catch ( undefined ) ) != undefined ) do
(
   ...
)

Oh right, thank you. I was looking for a solution where I can have more control over what’s going on. But I guess that’ll work for now.

Thank you

does someone know how I can only check the login, or the existing of a ftp folder?