Derefence a FtpListItem object asynchronously
Namespace: System.Net.FtpClient
Assembly: System.Net.FtpClient (in System.Net.FtpClient.dll) Version: 1.0.5064.17461
Syntax
C# |
---|
public IAsyncResult BeginDereferenceLink(
FtpListItem item,
int recMax,
AsyncCallback callback,
Object state
) |
Visual Basic |
---|
Public Function BeginDereferenceLink (
item As FtpListItem,
recMax As Integer,
callback As AsyncCallback,
state As Object
) As IAsyncResult |
Visual C++ |
---|
public:
IAsyncResult^ BeginDereferenceLink(
FtpListItem^ item,
int recMax,
AsyncCallback^ callback,
Object^ state
) |
Return Value
Type:
IAsyncResultIAsyncResult
Examples
C# |
Copy
|
using System;
using System.Net;
using System.Threading;
using System.Net.FtpClient;
namespace Examples {
static class BeginDereferenceLink {
static ManualResetEvent m_reset = new ManualResetEvent(false);
public static void BeginDereferenceLinkExample(FtpListItem item) {
using (FtpClient conn = new FtpClient()) {
m_reset.Reset();
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.Connect();
if (item.Type == FtpFileSystemObjectType.Link && item.LinkTarget != null) {
conn.BeginDereferenceLink(item, new AsyncCallback(DereferenceLinkCallback), conn);
m_reset.WaitOne();
}
conn.Disconnect();
}
}
static void DereferenceLinkCallback(IAsyncResult ar) {
FtpClient conn = ar.AsyncState as FtpClient;
FtpListItem target;
try {
if (conn == null)
throw new InvalidOperationException("The FtpControlConnection object is null!");
target = conn.EndDereferenceLink(ar);
if (target != null) {
}
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
|
See Also