Answer the question
In order to leave comments, you need to log in
How to upload a file to FTP (C#)?
There is this code:
string username = "username";
string Pass = "pass";
string URLpath = "ftp://serv.name/";
//string filePath = @"C:\somefile.txt";
try {
//filePath = FullPath.Text;
string filePath = @"C:\somefile.txt";
using(WebClient client = new WebClient()) {
client.Credentials = new NetworkCredential(username, Pass);
client.BaseAddress = URLpath;
client.UploadFile(WebRequestMethods.Ftp.UploadFile, filePath);
}
}
catch (Exception ex)
{
MessageBox(ex.Message, ex.Source);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question