c# - How can FTPClient delete a directory? -


i want delete folder in ftp.

can ftpclient object delete it?

ftpwebrequest provides delete action. here piece of code achieve :

               ftpwebrequest reqftp = ftpwebrequest.create(uri);                 // credentials , login handling...                  reqftp.method = webrequestmethods.ftp.deletefile;                  string result = string.empty;                 ftpwebresponse response = reqftp.getresponse();                 long size = response.contentlength;                 stream datastream = response.getresponsestream();                 streamreader sr = new streamreader(datastream);                 result = sr.readtoend();                 sr.close();                 datastream.close();                 response.close(); 

it should work on files , directories. indeed, please check have right permissions.

also, not delete folders while not empty. must traverse them recursively delete content before.

the exceptions thrown due right permissions problems not clear...


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -