CARVIEW |
Select Language
HTTP/2 200
date: Mon, 21 Jul 2025 09:12:17 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"475ac3e9a330890443f1c20e0041dd64"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=UJOQ%2FoFG2jzOGhqTyk%2BqssVIbOfQjaN%2B88zY0La5A92TkbQaECWnfIu6f5IzJB9e8%2BghzpmAk0A370rlhDrcQUyjO3W%2FBjef11ZYbEfSuCC21KKViIK1p6MtscIsq5qwMw%2FmdnBPTbHYescg8SxLVifQ06SV0HpwKxm0TzZzl0ZuPTyq5NB1hRLMqHhZmTihQp1MhVZrRp8Zj8cgNwf2LuGZ1NUQOV88PrdRv35EGahTDYV%2B1k0kr8OWp1blkcixtqXNNckyXTi8R2UKsPn4Hw%3D%3D--ZzO5a6Rn%2BdXyldVE--IzDXuP0MkFEcV3VeZ2pALA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1881506583.1753089136; Path=/; Domain=github.com; Expires=Tue, 21 Jul 2026 09:12:16 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Tue, 21 Jul 2026 09:12:16 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 968A:21415F:17FF391:1E721D3:687E0470
Quick Start Example · robinrodricks/FluentFTP Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 673
Quick Start Example
Robin Rodricks edited this page Sep 7, 2022
·
14 revisions
This code demonstrates the simplest possible way to connect to an FTP server and perform FTP operations. See below for the same example using async/await operators.
// create an FTP client and specify the host, username and password
// (delete the credentials to use the "anonymous" account)
var client = new FtpClient("123.123.123.123", "david", "pass123");
// connect to the server and automatically detect working FTP settings
client.AutoConnect();
// get a list of files and directories in the "/htdocs" folder
foreach (FtpListItem item in client.GetListing("/htdocs")) {
// if this is a file
if (item.Type == FtpObjectType.File) {
// get the file size
long size = client.GetFileSize(item.FullName);
// calculate a hash for the file on the server side (default algorithm)
FtpHash hash = client.GetChecksum(item.FullName);
}
// get modified date/time of the file or folder
DateTime time = client.GetModifiedTime(item.FullName);
}
// upload a file
client.UploadFile(@"C:\MyVideo.mp4", "/htdocs/MyVideo.mp4");
// move the uploaded file
client.MoveFile("/htdocs/MyVideo.mp4", "/htdocs/MyVideo_2.mp4");
// download the file again
client.DownloadFile(@"C:\MyVideo_2.mp4", "/htdocs/MyVideo_2.mp4");
// compare the downloaded file with the server
if (client.CompareFile(@"C:\MyVideo_2.mp4", "/htdocs/MyVideo_2.mp4") == FtpCompareResult.Equal) { }
// delete the file
client.DeleteFile("/htdocs/MyVideo_2.mp4");
// upload a folder and all its files
client.UploadDirectory(@"C:\website\videos\", @"/public_html/videos", FtpFolderSyncMode.Update);
// upload a folder and all its files, and delete extra files on the server
client.UploadDirectory(@"C:\website\assets\", @"/public_html/assets", FtpFolderSyncMode.Mirror);
// download a folder and all its files
client.DownloadDirectory(@"C:\website\logs\", @"/public_html/logs", FtpFolderSyncMode.Update);
// download a folder and all its files, and delete extra files on disk
client.DownloadDirectory(@"C:\website\dailybackup\", @"/public_html/", FtpFolderSyncMode.Mirror);
// delete a folder recursively
client.DeleteDirectory("/htdocs/extras/");
// check if a file exists
if (client.FileExists("/htdocs/big2.txt")) { }
// check if a folder exists
if (client.DirectoryExists("/htdocs/extras/")) { }
// upload a file and retry 3 times before giving up
client.Config.RetryAttempts = 3;
client.UploadFile(@"C:\MyVideo.mp4", "/htdocs/big.txt", FtpRemoteExists.Overwrite, false, FtpVerify.Retry);
// disconnect! good bye!
client.Disconnect();
This code demonstrates how to connect to an FTP server and perform FTP operations using async
/await
syntax in .NET 4.5 and later.
// create an FTP client and specify the host, username and password
// (delete the credentials to use the "anonymous" account)
var client = new AsyncFtpClient("123.123.123.123", "david", "pass123");
// connect to the server and automatically detect working FTP settings
await client.AutoConnect();
// get a list of files and directories in the "/htdocs" folder
foreach (FtpListItem item in await client.GetListing("/htdocs")) {
// if this is a file
if (item.Type == FtpObjectType.File) {
// get the file size
long size = await client.GetFileSize(item.FullName);
// calculate a hash for the file on the server side (default algorithm)
FtpHash hash = await client.GetChecksum(item.FullName);
}
// get modified date/time of the file or folder
DateTime time = await client.GetModifiedTime(item.FullName);
}
// upload a file
await client.UploadFile(@"C:\MyVideo.mp4", "/htdocs/MyVideo.mp4");
// move the uploaded file
await client.MoveFile("/htdocs/MyVideo.mp4", "/htdocs/MyVideo_2.mp4");
// download the file again
await client.DownloadFile(@"C:\MyVideo_2.mp4", "/htdocs/MyVideo_2.mp4");
// compare the downloaded file with the server
if (await client.CompareFile(@"C:\MyVideo_2.mp4", "/htdocs/MyVideo_2.mp4") == FtpCompareResult.Equal) { }
// delete the file
await client.DeleteFile("/htdocs/MyVideo_2.mp4");
// upload a folder and all its files
await client.UploadDirectory(@"C:\website\videos\", @"/public_html/videos", FtpFolderSyncMode.Update);
// upload a folder and all its files, and delete extra files on the server
await client.UploadDirectory(@"C:\website\assets\", @"/public_html/assets", FtpFolderSyncMode.Mirror);
// download a folder and all its files
await client.DownloadDirectory(@"C:\website\logs\", @"/public_html/logs", FtpFolderSyncMode.Update);
// download a folder and all its files, and delete extra files on disk
await client.DownloadDirectory(@"C:\website\dailybackup\", @"/public_html/", FtpFolderSyncMode.Mirror);
// delete a folder recursively
await client.DeleteDirectory("/htdocs/extras/");
// check if a file exists
if (await client.FileExists("/htdocs/big2.txt")) { }
// check if a folder exists
if (await client.DirectoryExists("/htdocs/extras/")) { }
// upload a file and retry 3 times before giving up
client.Config.RetryAttempts = 3;
await client.UploadFile(@"C:\MyVideo.mp4", "/htdocs/big.txt", FtpRemoteExists.Overwrite, false, FtpVerify.Retry);
// disconnect! good bye!
await client.Disconnect();
This code can also be found here within the FluentFTP repo:
Now that you've seen the basic usage, check out the other examples in C# or VB:
- Auto Connection
- Auto Reconnection
- FTP(S) Connection
- FTP(S) Connection using GnuTLS
- FTPS Proxies
- Custom Servers
- Custom Commands
- v40 Migration Guide
Clone this wiki locally
You can’t perform that action at this time.