“The remote server returned an error: (501) Syntax error in parameters or arguments.” when uploading TO FTP FROM Windows Azure


  • I need to continuously upload a generated file from Azure to client's FTP but when I run the code below it gives me ...

    The remote server returned an error: (501) Syntax error in parameters or arguments.

    ...also in Azure emulator it works fine.

    This is a proof of concept purposes draft code, so I did not use Worker role, queue or blob etc. intentionally..

    using System;

    using System.IO; using System.Net; using System.Web; namespace CloudWeb { public class Ftp : IHttpHandler { private const string FtpHost = "{0}"; private const string FtpUserName = "UserName"; private const string FtpPassword = "Password"; private const string WarningImageFile = "images/status_warning.png"; public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; UploadFtp(context.Server.MapPath(WarningImageFile)); context.Response.Write("Hello World"); } public bool IsReusable { get { return false; } } private static void UploadFtp(string source) { byte[] bFile = File.ReadAllBytes(source); var myFtp = (FtpWebRequest)WebRequest.Create(String.Format(FtpHost, Path.GetFileName(source))); myFtp.Method = WebRequestMethods.Ftp.UploadFile; myFtp.UsePassive = false; myFtp.UseBinary = true; myFtp.KeepAlive = true; myFtp.Credentials = new NetworkCredential(FtpUserName, FtpPassword); using (Stream clsStream = myFtp.GetRequestStream()) { clsStream.Write(bFile, 0, bFile.Length); clsStream.Close(); } myFtp = null; } } }

    Sunday, February 19, 2012 11:38 PM


All replies