C# .NET - The remote server returned an error: (530) Not logged in.

Asked By Az D on 30-May-12 02:15 AM

I have a simple code to delete files from FTP location .Below is my code:

foreach


(string s in filePaths)

{


FileInfo fi = new FileInfo(s);

string fileName = fi.Name;

FtpWebRequest requestFileDelete = (FtpWebRequest)WebRequest.Create(uripath + fileName);

requestFileDelete.Credentials = new NetworkCredential(username, password);

requestFileDelete.Method = WebRequestMethods.Ftp.DeleteFile;



FtpWebResponse responseFileDelete = (FtpWebResponse)requestFileDelete.GetResponse();

responseFileDelete.Close();

}

please help

Somesh Yadav replied to Az D on 30-May-12 02:31 AM
The server is sending you a message that you're not logged in. Could bedue to wrong url, invalid credentials, etc. As Javaman pointed above you need to see what is going on the wire and what commands are being exchanged. There are different ways to do this, I find it is easiest for me with a system.net trace log. Here are instructions on how to get the trace.

http://blogs.msdn.com/ncl/archive/2008/07/25/how-to-troubleshoot-your-system-net-code.aspx
Az D replied to Somesh Yadav on 30-May-12 02:34 AM
Hi Somesh,

The username password is correct, as i have connected with same credential via FieZilla
Az D replied to Somesh Yadav on 30-May-12 04:48 AM
To add more information the username contains '\' in it. ex : "abc\xyz"

I use it as below:

string username = "abc\\xyz";

Still not working.