I'm trying to upload a file to web using windows application(c#). I've tried this following code
private void uploadFile(string FTPAddress, string filePath, string username, string password)
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(FTPAddress + "/" + Path.GetFileName(filePath));
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(username, password);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
FileStream stream = File.OpenRead(filePath);
byte buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
and getting this following error while trying this
Quote:The remote name could not be resolved: 'username'
Can anyone please guide me?
Thanks in advance.
Edited 12-Feb-13 19:47pm
Try supplying a valid user name and password for the FTP service instead of "username".
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)