Upload a file to FTP

From Starfish ETL
Jump to navigation Jump to search

External Assemblies

To upload a file in a C# scripted function, you must first go to the .NET Global section, and in the External Assemblies box, enter the following: System.dll

void CSharpProcedure()
{
	var client = new System.Net.WebClient();
	string dt = DateTime.Now.ToString();
	dt = dt.Replace("/","-");
	dt = dt.Replace(" ","-");
	dt = dt.Replace(":","-");
	string URI = "ftp://ftp.site.com/PDFs/PDF-"+dt+".pdf";
	Starfish.LogMessage(URI);
	using (client)
	{
		client.Credentials = new System.Net.NetworkCredential("username", "password");
		client.UploadFile(URI, System.Net.WebRequestMethods.Ftp.UploadFile, @"C:\Results\NCOA\NCOA_CASS.pdf");
	}
}