I am using ASP.NET 2.0 and I am trying, for the firs ttime, to ftp a file through the app. There are serveral examples on the net. This one made the most sense to me. Being unsure of the actual local it will be going, right now, I decidied to FTP it right back to my local host, figuring I have the credential so it would be a goo dtest. However, it is failing with the following error: "Unable to connect to the remote server".
public void FTPFile()
{
string CompleteFTPPath = "ftp://localhost//WebSite1/test.txt";
string CompleteLocalPath = "C:\\test_file.txt";
//Create a FTP Request Object and Specfiy a Complete Path
FtpWebRequest reqObj = (FtpWebRequest)WebRequest.Create(CompleteFTPPath);
reqObj.Method = WebRequestMethods.Ftp.UploadFile;
reqObj.Credentials = new NetworkCredential("<my user name>", "<my pw>");
FileStream streamObj = File.OpenRead(CompleteLocalPath);
byte[] buffer = new byte[streamObj.Length];
streamObj.Read(buffer, 0, buffer.Length);
streamObj.Close();
streamObj = null;
reqObj.GetRequestStream().Write(buffer, 0, buffer.Length);
reqObj = null;
}