LocalDirectory="E:\demo\test.txt"
You gave it a file name, not a directory.
E:\demo\test.txt is a filename.
Here is the code from
try
{
UploadDirectory( LocalDirectory, "*.*", Recursive );
}
catch(FtpException caught)
{
Log.LogErrorFromException( caught, false );
Log.LogError( "Couldn't upload directory." );
return false;
}
foreach(string file in Directory.GetFiles( localPath, mask ))
{
String filename = Path.GetFileName( file );
Store( file, filename );
Log.LogMessage( MessageImportance.Low, "{0} uploaded succesfully.", localPath );
}
So what you're trying to do is essentially:
Directory.GetFiles( "E:\demo\test.txt" , "*.* ))
which isn't going to work.
Change it to:
LocalDirectory="E:\demo\"
Example code from the github link above.
/// <Target Name="DeployWebsite">
/// <FtpUploadDirectoryContent
/// ServerHost="ftp.myserver.com"
/// Port="42"
/// Username="user"
/// Password="p@ssw0rd"
/// LocalDirectory="c:\build\mywebsite"
/// RemoteDirectory="root\www\mywebsite"
/// Recursive="true"
/// />
Note: LocalDirectory does not refer to a filename.
If you want to upload a single file, here is a possible alternative:
https://www.assembla.com/spaces/GHFtpTask/wiki/Home/history
The main features of FtpTask for MSBuild are:
**Upload, download or delete a single file on a FTP server**
Recursively upload, download or delete a directory
Use multiple FTP connections simultaneously
FtpTask for MSBuild requires .NET 2.0.