Quantcast
Channel: Ftp.dll – Blog | Limilabs
Viewing all articles
Browse latest Browse all 15

FTP uploading files using patterns

$
0
0

Uploading files using patters is a unique feature of our FTP component. It allows you fast upload of files of certain types.

Here’s the sample that uploads all text files (*.txt) files from C drive, to newly created ‘Uploads’ folder on FTP server. The search includes all child folders recursively – note the true parameter in LocalSearchOptions constructor. Ftp component is going to create all necessary folders on the remote FTP server for you.

// C#

using (Ftp ftp = new Ftp())
{
    ftp.Connect("ftp.example.com");    // or ConnectSSL
    ftp.CreateFolder("Uploads");
    ftp.UploadFiles("Uploads", @"c:\", new LocalSearchOptions("*.txt", true));
    ftp.Close();
}
' VB.NET

Using ftp As New Ftp()
	ftp.Connect("ftp.example.com")    ' or ConnectSSL
	ftp.CreateFolder("Uploads")
	ftp.UploadFiles("Uploads", "c:\", New LocalSearchOptions("*.txt", True))
	ftp.Close()
End Using

You can also set LocalSearchOptions.UseRegex property to true, if you want to use regex patterns:

// C#

LocalSearchOptions options = new LocalSearchOptions(@"^.*\.txt$", true);
options.FolderPattern = @"^.*$";
options.UseRegex = true;

ftp.UploadFiles("Uploads", @"c:\", options);
' VB.NET

Dim options As New LocalSearchOptions("^.*\.txt$", True)
options.FolderPattern = "^.*$"
options.UseRegex = True

ftp.UploadFiles("Uploads", "c:\", options)

Viewing all articles
Browse latest Browse all 15

Trending Articles