fletchsod
Programmer
- Dec 16, 2002
- 181
I'm a bit stumped on this problem and wonder if anyone of you encountered this situation and know of a workaround to it.
This FtpWebRequest function worked great on a Windows 2003 Server when connecting to ftp.kbb.com ftp server but when I ran this application on Windows 2008 Server, it failed. This Windows 2008 Server is a new server.
When I opened up Windows-Explorer and typed the ftp.kbb.com in there, Windows-Explorer was able to connect to KBB Ftp Server in Windows 2008 Server.
What could be the problem?
The error message said "The remote server returned an error: (425) can't open data connection".
The stack trace showed this...
--snip--
Stack Trace: at System.Net.FtpWebRequest.CheckError()
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetResponse()
at Server_Admin_App.frmPopupFtpExplorerDialog.ftnFrmViewListFillerWithFtpData(String sFtpUrlAddress, String sFtpUserName, String sFtpPassword)'
--snip--
Anyone know? Thanks...
This FtpWebRequest function worked great on a Windows 2003 Server when connecting to ftp.kbb.com ftp server but when I ran this application on Windows 2008 Server, it failed. This Windows 2008 Server is a new server.
When I opened up Windows-Explorer and typed the ftp.kbb.com in there, Windows-Explorer was able to connect to KBB Ftp Server in Windows 2008 Server.
What could be the problem?
Code:
//Initialize variables...
System.IO.Stream oStream;
System.IO.StreamReader oStreamReader;
System.Net.FtpWebRequest oFtpWebRequest;
System.Net.FtpWebResponse oFtpWebResponse;
//Initialize variables...
string sLine = "";
ListViewItem oListViewItem = null;
string sSubLine = "";
Int32 iSubLine1 = 0;
Int32 iSubLine2 = 0;
string sFileSize = "";
string sFileDate = "";
string sFileName = "";
//Setup the ListView setting (this.lvKbbFtpSite)...
this.lvKbbFtpSite.MultiSelect = false;
this.lvKbbFtpSite.View = System.Windows.Forms.View.Details;
this.lvKbbFtpSite.Columns.Add("Name", 400, HorizontalAlignment.Left);
this.lvKbbFtpSite.Columns.Add("Size", 200, HorizontalAlignment.Left);
this.lvKbbFtpSite.Columns.Add("Date", 200, HorizontalAlignment.Left);
//Setup the ftp configuration...
oFtpWebRequest = (System.Net.FtpWebRequest)System.Net.WebRequest.Create(sFtpUrlAddress); // = System.Net.FtpWebRequest.(); // new System.Net.FtpWebRequest(); //= System.Net.FtpWebRequest.Create(sFtpUrlAddress);
oFtpWebRequest.KeepAlive = false;
oFtpWebRequest.UseBinary = true;
oFtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails;
oFtpWebRequest.UsePassive = false;
//oFtpWebRequest.Timeout = 18000; //(5 * 60 * 60); //Timeout in milliseconds...
//Connect to KBB ftp site...
//#oFtpWebRequest.Credentials = new System.Net.NetworkCredential(sFtpUserName, sFtpPassword, sFtpUrlAddress);
oFtpWebRequest.Credentials = new System.Net.NetworkCredential(sFtpUserName, sFtpPassword);
//Get ftp result...
oFtpWebResponse = (System.Net.FtpWebResponse)oFtpWebRequest.GetResponse();
//Debug only...
//MessageBox.Show("Ftp Status: " + oFtpWebResponse.StatusDescription.ToString());
//Loop through the ftp response...
oStream = oFtpWebResponse.GetResponseStream();
oStreamReader = new System.IO.StreamReader(oStream, System.Text.Encoding.UTF8);
//Blah blah...
The error message said "The remote server returned an error: (425) can't open data connection".
The stack trace showed this...
--snip--
Stack Trace: at System.Net.FtpWebRequest.CheckError()
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetResponse()
at Server_Admin_App.frmPopupFtpExplorerDialog.ftnFrmViewListFillerWithFtpData(String sFtpUrlAddress, String sFtpUserName, String sFtpPassword)'
--snip--
Anyone know? Thanks...