FtpWebRequest and the PWD, SIZE and MDTM methods

As you may have already noticed, the FtpResponseStream does not contain the result of PWD, SIZE and MDTM methods. You can get those from the FtpWebResponse properties   To get the result of the PWD method (WebRequestMethods.Ftp.PrintWorkingDirectory) check the FtpWebResponse.StatusDescription property To get the result of the SIZE method (WebRequestMethods.Ftp.GetFileSize) check FtpWebResponse.ContentLength property To get…

1

Using System.Net tracing to determining if SSL connection has been established with the server

For a detailed blog article on how to use System.Net Tracing go here http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspxPlease note that this feature is available in versions of the .Net Framework 2.0 (and above). In this concrete example I’ll be using HttpWebRequest, but you can use any other System.Net API that supports SSL. As an example I shall use the following…

3

RemoteEndPoint: Identifying the client from the server side

Variant 1: When using TcpListener class for our server there are 2 ways to get the underlying client             TcpClient client = listener.AcceptTcpClient();             IPEndPoint remoteEP = (IPEndPoint) client.Client.RemoteEndPoint;   or               Socket client = listener.AcceptSocket();             IPEndPoint remoteEP = (IPEndPoint) client.RemoteEndPoint;   Variant 2: When using the Socket class:             Socket client =…

3

Sending e-mail using SmtpClient and Gmail

The sample below used SmtpClient to send e-mail from your gmail account using your gmail username and password.     using System; using System.Net; using System.Net.Mail;   namespace GMailSample {     class SimpleSmtpSend     {         static void Main(string[] args)         {             SmtpClient client = new SmtpClient(“smtp.gmail.com”, 587);                        client.EnableSsl = true;             MailAddress from…

11

FtpWebRequest: Does the slash matter?

For those of you who are curious: there is indeed a difference when we use the following uris as parameters for our FtpWebRequest class: ftp://server/ParentDirectory ftp://server/ParentDirectory/ (Note the slash at the end)   Let’s say we want to create a new directory named “new” in “ParentDirectory”. With the first uri (without the slash) we issue: MKD…

2

Changing to the root directory with FtpWebRequest

Many customers ask us how they can use the CWD command with our FtpWebRequest. The answer is: you cannot use the command directly, but you can modify the uri parameter to achieve the same result. Let’s say you’re using the following format: String uri = “ftp://myFtpUserName:myFtpUserPassword@myFtpUrl“; FtpWebRequest Request = (FtpWebRequest)WebRequest.Create(uri); Request.Method = “LIST”; The above example will bring…

12