FtpClient.EndGetModifiedTime Method

System.Net.FtpClient

Collapse image Expand Image Copy image CopyHover image
Ends a call to BeginGetModifiedTime()

Namespace: System.Net.FtpClient
Assembly: System.Net.FtpClient (in System.Net.FtpClient.dll) Version: 1.0.5064.17461

Syntax

C#
public DateTime EndGetModifiedTime(
	IAsyncResult ar
)
Visual Basic
Public Function EndGetModifiedTime ( 
	ar As IAsyncResult
) As DateTime
Visual C++
public:
virtual DateTime EndGetModifiedTime(
	IAsyncResult^ ar
) sealed

Parameters

ar
Type: System..::..IAsyncResult
IAsyncResult returned from BeginGetModifiedTime()

Return Value

Type: DateTime
The modified time, DateTime.MinValue if there was a problem

Implements

IFtpClient..::..EndGetModifiedTime(IAsyncResult)

Examples

C#  Copy imageCopy
using System;
using System.Net;
using System.Net.FtpClient;
using System.Threading;

namespace Examples {
    public static class BeginGetModifiedTimeExample {
        static ManualResetEvent m_reset = new ManualResetEvent(false);

        public static void BeginGetModifiedTime() {
            using (FtpClient conn = new FtpClient()) {
                m_reset.Reset();

                conn.Host = "localhost";
                conn.Credentials = new NetworkCredential("ftptest", "ftptest");
                conn.Connect();
                conn.BeginGetModifiedTime("foobar", new AsyncCallback(BeginGetModifiedTimeCallback), conn);

                m_reset.WaitOne();
                conn.Disconnect();
            }
        }

        static void BeginGetModifiedTimeCallback(IAsyncResult ar) {
            FtpClient conn = ar.AsyncState as FtpClient;

            try {
                if (conn == null)
                    throw new InvalidOperationException("The FtpControlConnection object is null!");

                Console.WriteLine("Modify time: {0}", conn.EndGetModifiedTime(ar));
            }
            catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }
            finally {
                m_reset.Set();
            }
        }
    }
}

See Also