I am writing an application C# to download a file from ftp server, using Ftpwebrequest. I tested with a ftp server and my application worked fine. But when it works in real system (ftp server runs windows server 2008), it throw an exception: Error 550: the specified network name is no longer available. Anyone know how to resolve this problem? Thank you.
Asked
Active
Viewed 1,156 times
0
-
Without any code, we can only guess - but my guess is somewhere in your code or settings you are referring to a network name that exists in your development environment but is inaccessible in the production environment. I suggest you post your code and specify exactly where error is occurring. – Jon Roberts Feb 11 '20 at 17:19
-
Have you seen my code? – Duong Dang Feb 12 '20 at 21:57
-
Ftp server uses ports: 66, 68, 88..., not default port. Do they cause error? – Duong Dang Feb 12 '20 at 22:21
-
On the computer where you code isn't working, have you tried logging into the ftp server using the same credentials manually (e.g. via browser or other FTP client). Also check anti-virus and this post: https://stackoverflow.com/questions/44107643/c-sharp-ftp-response-550the-specified-network-name-is-no-longer-available – Jon Roberts Feb 13 '20 at 08:57
-
I tried connecting to ftp server with File zilla client and window explorer. They connect successfully. – Duong Dang Feb 13 '20 at 13:43
-
Ftp server use kaspersky anti virus. But I think it does not cause error because file zilla client abd window explorer still connect successfully – Duong Dang Feb 13 '20 at 14:24
-
It's the antivirus on the client PC you need to check in case it's wrongly identifying your program as a threat. Maybe briefly disable the AV & Firewall on the client PC while you test to rule it out. Try it on other PCs. Double check it really does run compiled on your PC. Write trace lines in your code to print out status / erro info when running on client PC. Basically keep testing till something exceptional or some pattern emerges that will give you a clue on where to look. – Jon Roberts Feb 13 '20 at 16:00
-
I tried to disabled antivrus, firewall and window defender but it still has error – Duong Dang Feb 14 '20 at 13:29
1 Answers
0
Sorry I forgot to post my code:
public static bool TestConnection(string IPAdd, string port, string username, string password)
{
try
{
var downloadRequest = (FtpWebRequest)WebRequest.Create(@"ftp://" + IPAdd + ":" + port);
downloadRequest.Credentials = new NetworkCredential(username, password);
downloadRequest.Method = WebRequestMethods.Ftp.ListDirectory;
var ftpWebResponse = (FtpWebResponse)downloadRequest.GetResponse();
ftpWebResponse.Close();
return true;
}
catch (Exception)
{
return false;
}
}

Duong Dang
- 1
- 1