Skip to content

Commit

Permalink
fix AsyncFtpClient in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
robinrodricks committed Aug 27, 2022
1 parent 69910d6 commit 959ead7
Show file tree
Hide file tree
Showing 58 changed files with 72 additions and 64 deletions.
4 changes: 2 additions & 2 deletions FluentFTP.CSharpExamples/Connect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void ConnectAlt() {
public static async Task ConnectAsync() {
var token = new CancellationToken();

using (var conn = new FtpClient()) {
using (var conn = new AsyncFtpClient()) {
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");

Expand All @@ -39,7 +39,7 @@ public static async Task ConnectAsync() {
public static async Task ConnectAsyncAlt() {
var token = new CancellationToken();

using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {

await conn.ConnectAsync(token);
}
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/ConnectFTPS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void ConnectFTPS() {

public static async Task ConnectFTPSAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {

conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateAnyCertificate = true;
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/ConnectFTPSCertificate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void ConnectFTPSCertificate() {

public static async Task ConnectFTPSCertificateAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {

conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
Expand Down
6 changes: 4 additions & 2 deletions FluentFTP.CSharpExamples/ConnectProxyHttp11.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using FluentFTP;
using FluentFTP.Proxy;
using FluentFTP.Proxy.AsyncProxy;
using FluentFTP.Proxy.SyncProxy;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -25,7 +27,7 @@ internal static class ConnectProxyHttp11 {
public static void ConnectAndGetListing() {

// create an FTP client connecting through a HTTP 1.1 Proxy
FtpClient client = new FtpClientHttp11Proxy(new FtpProxyProfile() {
var client = new FtpClientHttp11Proxy(new FtpProxyProfile() {
ProxyHost = proxy_host,
ProxyPort = proxy_port,
ProxyCredentials = new NetworkCredential(proxy_user, proxy_pass),
Expand Down Expand Up @@ -69,7 +71,7 @@ public static void ConnectAndGetListing() {
public static void ConnectAndManipulate() {

// create an FTP client connecting through a HTTP 1.1 Proxy
FtpClient client = new FtpClientHttp11Proxy(new FtpProxyProfile() {
var client = new FtpClientHttp11Proxy(new FtpProxyProfile() {
ProxyHost = proxy_host,
ProxyPort = proxy_port,
ProxyCredentials = new NetworkCredential(proxy_user, proxy_pass),
Expand Down
6 changes: 4 additions & 2 deletions FluentFTP.CSharpExamples/ConnectProxySocks4.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using FluentFTP;
using FluentFTP.Proxy;
using FluentFTP.Proxy.AsyncProxy;
using FluentFTP.Proxy.SyncProxy;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -25,7 +27,7 @@ internal static class ConnectProxySocks4 {
public static void ConnectAndGetListing() {

// create an FTP client connecting through a SOCKS4 Proxy
FtpClient client = new FtpClientSocks4Proxy(new FtpProxyProfile() {
var client = new FtpClientSocks4Proxy(new FtpProxyProfile() {
ProxyHost = proxy_host,
ProxyPort = proxy_port,
ProxyCredentials = new NetworkCredential(proxy_user, proxy_pass),
Expand Down Expand Up @@ -69,7 +71,7 @@ public static void ConnectAndGetListing() {
public static void ConnectAndManipulate() {

// create an FTP client connecting through a SOCKS4 Proxy
FtpClient client = new FtpClientSocks4Proxy(new FtpProxyProfile() {
var client = new FtpClientSocks4Proxy(new FtpProxyProfile() {
ProxyHost = proxy_host,
ProxyPort = proxy_port,
ProxyCredentials = new NetworkCredential(proxy_user, proxy_pass),
Expand Down
6 changes: 4 additions & 2 deletions FluentFTP.CSharpExamples/ConnectProxySocks4a.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using FluentFTP;
using FluentFTP.Proxy;
using FluentFTP.Proxy.AsyncProxy;
using FluentFTP.Proxy.SyncProxy;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -25,7 +27,7 @@ internal static class ConnectProxySocks4a {
public static void ConnectAndGetListing() {

// create an FTP client connecting through a SOCKS4a Proxy
FtpClient client = new FtpClientSocks4aProxy(new FtpProxyProfile() {
var client = new FtpClientSocks4aProxy(new FtpProxyProfile() {
ProxyHost = proxy_host,
ProxyPort = proxy_port,
ProxyCredentials = new NetworkCredential(proxy_user, proxy_pass),
Expand Down Expand Up @@ -69,7 +71,7 @@ public static void ConnectAndGetListing() {
public static void ConnectAndManipulate() {

// create an FTP client connecting through a SOCKS4a Proxy
FtpClient client = new FtpClientSocks4aProxy(new FtpProxyProfile() {
var client = new FtpClientSocks4aProxy(new FtpProxyProfile() {
ProxyHost = proxy_host,
ProxyPort = proxy_port,
ProxyCredentials = new NetworkCredential(proxy_user, proxy_pass),
Expand Down
6 changes: 4 additions & 2 deletions FluentFTP.CSharpExamples/ConnectProxySocks5.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using FluentFTP;
using FluentFTP.Proxy;
using FluentFTP.Proxy.AsyncProxy;
using FluentFTP.Proxy.SyncProxy;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -26,7 +28,7 @@ internal static class ConnectProxySocks5 {
public static void ConnectAndGetListing() {

// create an FTP client connecting through a SOCKS5 Proxy
FtpClient client = new FtpClientSocks5Proxy(new FtpProxyProfile() {
var client = new FtpClientSocks5Proxy(new FtpProxyProfile() {
ProxyHost = proxy_host,
ProxyPort = proxy_port,
ProxyCredentials = new NetworkCredential(proxy_user, proxy_pass),
Expand Down Expand Up @@ -70,7 +72,7 @@ public static void ConnectAndGetListing() {
public static void ConnectAndManipulate() {

// create an FTP client connecting through a SOCKS5 Proxy
FtpClient client = new FtpClientSocks5Proxy(new FtpProxyProfile() {
var client = new FtpClientSocks5Proxy(new FtpProxyProfile() {
ProxyHost = proxy_host,
ProxyPort = proxy_port,
ProxyCredentials = new NetworkCredential(proxy_user, proxy_pass),
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/CreateDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void CreateDirectory() {

public static async Task CreateDirectoryAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

await conn.CreateDirectoryAsync("/test/path/that/should/be/created", true, token);
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/DeleteDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void DeleteDirectory() {

public static async Task DeleteDirectoryAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

// Remove the directory and all files and subdirectories inside it
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/DeleteFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void DeleteFile() {

public static async Task DeleteDirectoryAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

await conn.DeleteFileAsync("/full/or/relative/path/to/file", token);
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/DirectoryExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void DirectoryExists() {

public static async Task DirectoryExistsAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

if (await conn.DirectoryExistsAsync("/full/or/relative/path", token)) {
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/DownloadDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void DownloadDirectory() {

public static async Task DownloadDirectoryAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);


Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/DownloadDirectoryWithRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void DownloadDirectoryWithRules() {

public static async Task DownloadDirectoryWithRulesAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);


Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/DownloadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void DownloadFile() {

public static async Task DownloadFileAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);

// download a file and ensure the local directory is created
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/DownloadFileWithProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void DownloadFile() {

public static async Task DownloadFileAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);

// define the progress tracking callback
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/DownloadManyFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void DownloadFiles() {

public static async Task DownloadFilesAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);

// download many files, skip if they already exist on disk
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/ExecuteFTPCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void Execute() {

public static async Task ExecuteAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

FtpReply reply;
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/FileExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void FileExists() {

public static async Task FileExistsAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

// The last parameter forces FluentFTP to use LIST -a
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/GetChecksum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void GetChecksum() {

public static async Task GetChecksumAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

// Get a hash checksum for the file
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/GetFileSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void GetFileSize() {

public static async Task GetFileSizeAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

Console.WriteLine("The file size is: " + await conn.GetFileSizeAsync("/full/or/relative/path/to/file", -1, token));
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/GetListing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void GetListing() {

public static async Task GetListingAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

// get a recursive listing of the files & folders in a specific folder
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/GetModifiedTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void GetModifiedTime() {

public static async Task GetModifiedTimeAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

Console.WriteLine("The modified type is: " +
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/GetNameListing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void GetNameListing() {

public static async Task GetNameListingAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

foreach (var s in await conn.GetNameListingAsync(token)) {
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/GetWorkingDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void GetWorkingDirectory() {

public static async Task GetWorkingDirectoryAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

Console.WriteLine("The working directory is: " + await conn.GetWorkingDirectoryAsync(token));
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/Rename.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void Rename() {

public static async Task RenameAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);

// renaming a directory is dependent on the server! if you attempt it
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/SetWorkingDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void SetWorkingDirectory() {

public static async Task SetWorkingDirectoryAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var conn = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {

await conn.ConnectAsync(token);
await conn.SetWorkingDirectoryAsync("/full/or/relative/path", token);
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/UploadDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void UploadDirectory() {

public static async Task UploadDirectoryAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);


Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/UploadDirectoryWithRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void UploadDirectoryWithRules() {

public static async Task UploadDirectoryWithRulesAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);


Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/UploadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void UploadFile() {

public static async Task UploadFileAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);

// upload a file to an existing FTP directory
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/UploadFileWithProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void UploadFile() {

public static async Task UploadFileAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);

// define the progress tracking callback
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.CSharpExamples/UploadManyFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void UploadFiles() {

public static async Task UploadFilesAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);

// upload many files, skip if they already exist on server
Expand Down
4 changes: 2 additions & 2 deletions FluentFTP.VBExamples/Connect.vb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Namespace Examples
Async Function ConnectAsync() As Task
Dim token = New CancellationToken()

Using conn = New FtpClient()
Using conn = New AsyncFtpClient()
conn.Host = "localhost"
conn.Credentials = New NetworkCredential("ftptest", "ftptest")
Await conn.ConnectAsync(token)
Expand All @@ -33,7 +33,7 @@ Namespace Examples
Async Function ConnectAsyncAlt() As Task
Dim token = New CancellationToken()

Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest")
Using conn = New AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")
Await conn.ConnectAsync(token)
End Using
End Function
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.VBExamples/ConnectFTPS.vb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Namespace Examples
Async Function ConnectFTPSAsync() As Task
Dim token = New CancellationToken()

Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest")
Using conn = New AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")
conn.EncryptionMode = FtpEncryptionMode.Explicit
conn.ValidateAnyCertificate = True
Await conn.ConnectAsync(token)
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP.VBExamples/ConnectFTPSCertificate.vb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Namespace Examples
Async Function ConnectFTPSCertificateAsync() As Task
Dim token = New CancellationToken()

Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest")
Using conn = New AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")
conn.EncryptionMode = FtpEncryptionMode.Explicit
AddHandler conn.ValidateCertificate, New FtpSslValidation(AddressOf OnValidateCertificate)
Await conn.ConnectAsync(token)
Expand Down
Loading

0 comments on commit 959ead7

Please sign in to comment.