Timeout i system.net.ftpclient
Hej,jeg har et problem med et FTP-script. Meningen med scriptet er at hente en filliste, og dernæst læse indholdet i hver fil og analysere det.
Jeg kan sagtens hente fillisten, som indeholder 35 filnavne. Men når jeg prøver at indlæse filerne i en stream, når den kun 9 filer igennem før jeg får en timeout.
Fejlen ser sådan ud:
"An exception of type 'System.IO.IOException' occurred in mscorlib.dll but was not handled in user code
Additional information: The connection was terminated before a greeting could be read."
Kode:
FtpClient ftp = new FtpClient();
ftp.Host = "xx";
ftp.Credentials = new System.Net.NetworkCredential("xx", "xx");
ftp.DataConnectionReadTimeout = 100000000; // Testing
ftp.DataConnectionType = FtpDataConnectionType.AutoPassive;
ftp.ReadTimeout = 100000000; // Testing
// Checking if the iNews rundown exist
try
{
await ftp.SetWorkingDirectoryAsync(iNewsRundown.Text);
}
// If not, about the function and display an errormessage
catch (Exception s)
{
MessageBox.Show("The specified rundown in iNews does not exist. " + System.Environment.NewLine + System.Environment.NewLine + s);
return;
}
// Clearing the window
StatusWindow.Clear();
// Going through all the files set in WorkingDirectory
foreach (FtpListItem item in ftp.GetListing(ftp.GetWorkingDirectory(),
FtpListOption.Modify | FtpListOption.Size))
{
StatusWindow.ScrollToCaret();
// Reading iNews file
switch (item.Type)
{
// If a file, then take action
case FtpFileSystemObjectType.File:
// Write the name in the StatusWindow
StatusWindow.AppendText(item.Name + System.Environment.NewLine);
// Read the content of the file
Stream stream = await ftp.OpenReadAsync(item.Name);
Denne sidste linie er skurken...
Hjælp påskønnes... :-)