繁体   English   中英

错误 550:使用 C# 从 ftp 服务器下载文件时,指定的网络名称不再可用

[英]Error 550: the specified network name is no longer available when download file from ftp server with C#

我正在编写一个应用程序 C# 来使用 Ftpwebrequest 从 ftp 服务器下载文件。 我使用 ftp 服务器进行了测试,我的应用程序运行良好。 但是当它在真实系统中工作时(ftp服务器运行的是windows server 2008),它会抛出一个异常:错误550:指定的网络名称不再可用 有谁知道如何解决这个问题? 谢谢你。

对不起,我忘了发布我的代码:

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;
        }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM