Asynchronously removes a directory from the server
Namespace: System.Net.FtpClient
Assembly: System.Net.FtpClient (in System.Net.FtpClient.dll) Version: 1.0.5064.17461
Syntax
C# |
---|
public IAsyncResult BeginDeleteDirectory(
string path,
AsyncCallback callback,
Object state
) |
Visual Basic |
---|
Public Function BeginDeleteDirectory (
path As String,
callback As AsyncCallback,
state As Object
) As IAsyncResult |
Visual C++ |
---|
public:
virtual IAsyncResult^ BeginDeleteDirectory(
String^ path,
AsyncCallback^ callback,
Object^ state
) sealed |
Return Value
Type:
IAsyncResultIAsyncResult
Implements
IFtpClient..::..BeginDeleteDirectory(String, AsyncCallback, Object)
Examples
C# |
Copy
|
using System;
using System.Net;
using System.Net.FtpClient;
using System.Threading;
namespace Examples {
class BeginDeleteDirectoryExample {
static ManualResetEvent m_reset = new ManualResetEvent(false);
public static void BeginDeleteDirectory() {
using (FtpClient conn = new FtpClient()) {
m_reset.Reset();
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.CreateDirectory("/some/test/directory");
conn.BeginDeleteDirectory("/some", true, new AsyncCallback(DeleteDirectoryCallback), conn);
m_reset.WaitOne();
conn.Disconnect();
}
}
static void DeleteDirectoryCallback(IAsyncResult ar) {
FtpClient conn = ar.AsyncState as FtpClient;
try {
if (conn == null)
throw new InvalidOperationException("The FtpControlConnection object is null!");
conn.EndDeleteDirectory(ar);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
|
See Also