I'm testing the following code for replacing files on a https site via C# code, but it has no effect and generates no exception. (Downloading files works fine).
try
{
using (System.Net.WebClient client = new System.Net.WebClient())
{
client.Credentials = new System.Net.NetworkCredential(username, password);
//www.testsite.com is just an example - testing is done with an actual site:
client.UploadFile("https://www.testsite.com/testfolder/testpage.html", @"C:\testuploads\testpage.html");
//same effect using the 3-param version - no effect + no exception:
//client.UploadFile("https://www.testsite.com/testfolder/testpage.html", System.Net.WebRequestMethods.Ftp.UploadFile, @"C:\testuploads\testpage.html");
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
This post mentioned the need for server-side code: WebClient UploadFile Does Not Work
But how does an FTP client tool such as FileZilla Client accomplish this? Surely it doesn't install server-side code. (FileZilla Client replaces the file without issue).