I have created a small windows forms application to upload the file to one of our client\'s ftp site. But the problem that I\'m having is that when I run this application on
Make sure target folder "outbox" exists. That was my problem with error 550.
Simply create target directory "output" before upload.
try
{
WebRequest request = WebRequest.Create("ftp://" + ftpServerIP + "/outbox");
request.Credentials = new NetworkCredential("user", "password");
request.Method = WebRequestMethods.Ftp.MakeDirectory;
using (var resp = (FtpWebResponse)request.GetResponse())
{
Console.WriteLine(resp.StatusCode);
}
}
catch (WebException ex)
{
FtpWebResponse response = (FtpWebResponse)ex.Response;
if (response.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
{
response.Close();
//already exists
}
else
{
response.Close();
//doesn't exists = it's another exception
}
}