Home All Groups Group Topic Archive Search About

FtpWebRequest.Method

Author
16 Mar 2007 4:12 PM
Ulf_Jaenicke-Rößler
Hi -

how can I send arbitrary commands to an FTP server by FtpWebRequest class?

Every command that is not explicitely contained in WebRequestMethods.Ftp
yields an exception of type ArgumentException. Why?

The docs (ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.de/cpref10/html/P_System_Net_FtpWebRequest_Method.htm)
say, I can use any string that is supported by the server.

Sample code:

      Uri ftpUri = new Uri("ftp://localhost//sample.txt");
      FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUri);
      request.Credentials = new NetworkCredential("user","pass");
      request.UsePassive=true;
      request.Method="dir";                     // ArgumentException here
      FtpWebResponse response = (FtpWebResponse)request.GetResponse();
      response.Close();


If I would use
      request.Method="list";
it works.

Any idea?
Thanks!

AddThis Social Bookmark Button