1
我有一個當前的連接方法會在哪裏FTP別名進入.NET中的FTP連接
ftp ftpClient = new ftp(@"ftp://testftp/", @"username", @"password", false);
string[] dirlist = ftpClient.directoryListSimple("/");
foreach (var x in dirlist) { Console.WriteLine(x); }
Console.ReadKey();
這是FTP類的目錄列表
public class ftp
{
private string host = null;
private string user = null;
private string pass = null;
private FtpWebRequest ftpRequest = null;
private FtpWebResponse ftpResponse = null;
private Stream ftpStream = null;
private int bufferSize = 2048;
private bool enableSSL = true;
/* List Directory Contents File/Folder Name Only */
public string[] directoryListSimple(string directory)
{
try
{
/* Create an FTP Request */
ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + directory);
/* Log in to the FTP Server with the User Name and Password Provided */
ftpRequest.Credentials = new NetworkCredential(user, pass);
/* When in doubt, use these options */
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = false;
ftpRequest.KeepAlive = true;
/* EnableSSL if required, most times false */
ftpRequest.EnableSsl = enableSSL;
/* Specify the Type of FTP Request */
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
/* Establish Return Communication with the FTP Server */
ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
/* Establish Return Communication with the FTP Server */
ftpStream = ftpResponse.GetResponseStream();
/* Get the FTP Server's Response Stream */
StreamReader ftpReader = new StreamReader(ftpStream);
/* Store the Raw Response */
string directoryRaw = null;
/* Read Each Line of the Response and Append a Pipe to Each Line for Easy Parsing */
try { while (ftpReader.Peek() != -1) { directoryRaw += ftpReader.ReadLine() + "|"; } }
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
/* Resource Cleanup */
ftpReader.Close();
ftpStream.Close();
ftpResponse.Close();
ftpRequest = null;
/* Return the Directory Listing as a string Array by Parsing 'directoryRaw' with the Delimiter you Append (I use | in This Example) */
try { string[] directoryList = directoryRaw.Split("|".ToCharArray()); return directoryList; }
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
}
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
/* Return an Empty string Array if an Exception Occurs */
return new string[] { "" };
}
}
的代碼,然後我嘗試運行目錄列表,這在測試設置中非常完美。
然而,當我去與我們的合作伙伴之一,我得到530未登錄
我在Chrome測試,它的精細記錄並顯示目錄列表
我與SSL試過,不,主動,被動無效
我能想到的最後一件事是他們提供了一個別名,但我不知道它會去哪裏。在谷歌,他們說的做testftp |別名,但沒有因URI格式
任何幫助,將不勝感激