Hi,
I have a FTP access (hostname, username, password).
I want to get the name of the unique folder (there is only one here) at the root like so:
Depends on the username, the folder has a different name, that's why I want to get it to copy some files in this one.
There is no access to write anything at this level.
In Python it's simple with the ftplib class:
from ftplib import FTP
ftp = FTP('hostname')
ftp.login('userName','password')
ftp.retrlines('LIST')
ftp.quit()
It prints out the folder name and some other information.
In dotNet, we have the class WebClient, FtpWebRequest, and FtpWebResponse. I'm confused with all these methods.
All I have so far can chek if the connection has succeeded or not, plus the "StatusDescription".
But it's not at all what I am looking for because I have to know the folder name at the start.
clearlistener()
FTP = "ftp://hostname//folderName/"
userName = "username"
password = "password"
theRemote = FTP + "test.zip"
clsRequest = (dotNetClass "System.Net.FtpWebRequest").Create theRemote
clsRequest.Credentials = dotNetObject "System.Net.NetworkCredential" userName password
clsRequest.Method = "STOR" -- "LIST"
try
(
response = clsRequest.GetResponse()
print (response.StatusDescription)
response.Close()
response.Dispose()
print "Connected"
)
catch
(
print "Error"
)
By Rodman · 2014-01-14
barigazy · 2014-01-14