I have tried every variation of the below I can think of.
client.Credentials = new NetworkCredential(ftpInfo.ftpUserName, ftpInfo.ftpPassWord);
client.BaseAddress = "ftp://99.999.9.99";
var response = client.UploadFile("testFile.txt", "C:\\ftproot\\testfile\\012\\Drop\\testFile.txt");
I know the username and password are correct. If I connect to the server using filezilla from the same box it works.
I have tried not haivng ftp:// on it -- I have to be missing something very simple.
Here is the error: {"Unable to connect to the remote server"}
- Response {System.Net.FtpWebResponse} System.Net.WebResponse {System.Net.FtpWebResponse}
- ContentType '($exception).Response.ContentType' threw an exception of type 'System.NotImplementedException' string {System.NotImplementedException}
UPDATE: I don't know what is wrong with the question. I have given as much info as I have on it.
Here is a current test using some of the suggestions in the notes.
using (WebClient client = new WebClient())
{
client.Credentials = new NetworkCredential("password", "loginname");
client.UploadFile("ftp://99.999.6.130/testFile.txt", "STOR", "c:\\testfile.txt");
}
That just states that I am not logged in.
The below is working....I will close the question out when it lets me.
Finale Update -- working solution:
public static bool UploadFile(string url, string userName, string password, string file, out string statusDescription)
{
try
{
var request = (FtpWebRequest)WebRequest.Create(url);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(userName, password);
// Copy the entire contents of the file to the request stream.
var sourceStream = new StreamReader(file);
var fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
var getResponse = request.GetResponse();
Console.WriteLine($"{fileContents.Length} {getResponse} ");
}
}