FTP RMD (delete/remove directory) doesnt work!

This code runs in a C# application well and without throwing any error:

public void DeleteDirectory(string emptyDirectoryToBeDeleted)
{
try
{
ftpRequest = (FtpWebRequest)WebRequest.Create(host + “/” + emptyDirectoryToBeDeleted);
ftpRequest.Credentials = new NetworkCredential(user, pass);
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = true;
ftpRequest.KeepAlive = true;
ftpRequest.Method = WebRequestMethods.Ftp.RemoveDirectory;
ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
ftpResponse.Close();
ftpRequest = null;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

Emnbeddedin an Editor Script it throws this error:
“Support for command RMD not implemented yet”

Any idea how to delete a ftp directory via Unity Editor script?

Unity uses the Mono framework and Mono itself is missing the functionality. Your only options are basically to use a third party asset that completely implements the functionality you need or implement it yourself. I’ll link the standard below.

https://www.ietf.org/rfc/rfc959.txt

Accordinging to https://forums.xamarin.com/discussion/15663/ftpwebrequest-support-for-command-rmd-not-implemented… Now keep in mind this post in a bit dated. So I’d read that page and do what that guy says about talking to mono-project or just do more research on the topic.

Xamarin’s bug tracker has a newer entry for it (April 28th 2016). At the time it still had not been implemented.

https://bugzilla.xamarin.com/show_bug.cgi?id=40756

I wouldn’t expect them to fully implement it at this point either. FTP is very vulnerable.

https://en.wikipedia.org/wiki/File_Transfer_Protocol#Security

One of the biggest flaws is that everything you transmit (usernames, passwords, etc) are in clear text.

2 Likes

Thanks for your answers, tips, hints etc.!
One year later I can say that I feel much more comfortable with unity … and that I wrote in the meantime my own SFTP unity plugIn.

(And sorry for the really very very late response :frowning: )

Is there a follow-up?
I currently have the same problem.
And I use FluentFTP’s DeleteDirectory does not work.

The OP has not been seen since february 2020…

But @Ryiah is still active on the forums, there is a chance they may be able to point you in the right direction (Although as far as I can see all the info required already exists in this thread…)

My English is not very good,
I’m sorry I don’t quite understand what you are talking about?
What does OP mean?
In addition, do you mean that this discussion thread already has a solution to use ftp and delete the directory in unity?

I’m not aware of anything changing but then I don’t make it a habit to play with outdated features. Microsoft owns Mono now and the stance they have taken per their documentation is that you shouldn’t be using FtpWebRequest which implies to me that it will be removed at some point in the future.

If someone wants folders removed from a server the best way to handle this is to have an app running on the server that handles the deletion. That way you can encrypt your traffic too since FTP is once again a massive security risk. Anyone with any sense stopped using it a decade ago.

1 Like

Is it not recommended to use FTP or to use FtpWebRequest?

If it is not recommended to use FtpWebRequest,
Is there any other way?
At present, I only have the function of deleting the directory which cannot be realized.

Understood, thank you very much! : )

If I were hitting this issue, I’d just have the Unity build execute the ftp console command.