 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
David Ayre Guest
|
Posted: Wed Feb 14, 2007 7:18 pm Post subject: IdFTP1->List problem |
|
|
Hi,
I am using Indy 9 with BDS 2006 but have found a problem with the
ftp module when I use IdFTP1->List(SL,"",false); If there is
nothing in the folder it crashes. What can I do to avoid this?
Cheers,
David |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Feb 15, 2007 12:02 am Post subject: Re: IdFTP1->List problem |
|
|
"David Ayre" <davidcayre (AT) ntlworld (DOT) com> wrote in message
news:45d30c11$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I am using Indy 9 with BDS 2006 but have found a problem
with the ftp module when I use IdFTP1->List(SL,"",false); If
there is nothing in the folder it crashes.
|
The server is likely sending back a faulty reply. Look at the "Indy
FTP Response Codes for NLST" discussion in the
"borland.public.delphi.internet.winsock" newsgroup from last night.
Gambit |
|
| Back to top |
|
 |
David Ayre Guest
|
Posted: Thu Feb 15, 2007 4:07 pm Post subject: Re: IdFTP1->List problem |
|
|
"Remy Lebeau \(TeamB\)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
"David Ayre" <davidcayre (AT) ntlworld (DOT) com> wrote in message
news:45d30c11$1 (AT) newsgroups (DOT) borland.com...
I am using Indy 9 with BDS 2006 but have found a problem
with the ftp module when I use IdFTP1->List(SL,"",false); If
there is nothing in the folder it crashes.
The server is likely sending back a faulty reply. Look at the "Indy
FTP Response Codes for NLST" discussion in the
"borland.public.delphi.internet.winsock" newsgroup from last night.
Gambit
I've had a look at the NLST discussion but couldn't glean |
anything that would help me.
If the server gives the wrong response to IdFTP1->List(SL,"",false);
for an empty folder, how can I detect this and continue,
ignoring the List(), which would then be unnecessary?
David |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Thu Feb 15, 2007 8:41 pm Post subject: Re: IdFTP1->List problem |
|
|
| Quote: | If the server gives the wrong response to IdFTP1->List(SL,"",false);
for an empty folder, how can I detect this and continue,
|
Indy uses Exceptions therefore if a bad response is received an exception
should be thrown. That being the case you need to use try/catch to catch
the exceptions and deal with them accordingly.
If an exception isn't thrown, you should check the response code that
is returned and determine your action from there.
Regards,
Tom |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Feb 15, 2007 11:38 pm Post subject: Re: IdFTP1->List problem |
|
|
"David Ayre" <davidcayre (AT) ntlworld (DOT) com> wrote in message
news:45d430c5$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I've had a look at the NLST discussion but couldn't glean
anything that would help me.
|
Then I suggest you use a packet sniffer, such as Ethereal, to find out
exactly what the server is sending.
Gambit |
|
| Back to top |
|
 |
David Ayre Guest
|
Posted: Fri Feb 16, 2007 12:57 am Post subject: Re: IdFTP1->List problem |
|
|
"Tom" <tom (AT) nospam (DOT) net> wrote:
| Quote: | If the server gives the wrong response to IdFTP1->List(SL,"",false);
for an empty folder, how can I detect this and continue,
Indy uses Exceptions therefore if a bad response is received an exception
should be thrown. That being the case you need to use try/catch to catch
the exceptions and deal with them accordingly.
If an exception isn't thrown, you should check the response code that
is returned and determine your action from there.
Regards,
Tom
Thanks Tom, |
I thought something like that would do it, but I'm not sure how
to set it out. Could you possibly give me a code example.
Cheers,
David |
|
| Back to top |
|
 |
Tom Guest
|
Posted: Fri Feb 16, 2007 7:53 am Post subject: Re: IdFTP1->List problem |
|
|
David,
Without knowing the exact exception that's being thrown, I can only
give you a general try catch example. Once you get the exception
name I would only catch that exception so you can deal with any
others that may show up accordlingly.
try
{
IdFTP1->List(SL, "", false);
}
catch (Exception &e)
{
// This will catch every exception and handle them the same
// way. If you have different exceptions coming up, you need to
// catch them separately by using the proper names.
// IE: catch (EIdSocketError &e) or catch (EIdProtocolReplyError)
// If you need to do something special, put that code here.
// otherwise the error message will disappear. Please remember
// that the error will still be shown if you're using the debugger.
}
Regards,
Tom |
|
| Back to top |
|
 |
David Ayre Guest
|
Posted: Fri Feb 16, 2007 8:25 pm Post subject: Re: IdFTP1->List problem |
|
|
Thanks Tom,
That seems to have solved the problem.
Cheers,
David
"Tom" <tom (AT) nospam (DOT) net> wrote:
| Quote: | David,
Without knowing the exact exception that's being thrown, I can only
give you a general try catch example. Once you get the exception
name I would only catch that exception so you can deal with any
others that may show up accordlingly.
try
{
IdFTP1->List(SL, "", false);
}
catch (Exception &e)
{
// This will catch every exception and handle them the same
// way. If you have different exceptions coming up, you need to
// catch them separately by using the proper names.
// IE: catch (EIdSocketError &e) or catch (EIdProtocolReplyError)
// If you need to do something special, put that code here.
// otherwise the error message will disappear. Please remember
// that the error will still be shown if you're using the debugger.
}
Regards,
Tom
|
|
|
| Back to top |
|
 |
David Ayre Guest
|
Posted: Mon Feb 19, 2007 1:06 am Post subject: Re: IdFTP1->List problem |
|
|
"Remy Lebeau \(TeamB\)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
"David Ayre" <davidcayre (AT) ntlworld (DOT) com> wrote in message
news:45d430c5$1 (AT) newsgroups (DOT) borland.com...
I've had a look at the NLST discussion but couldn't glean
anything that would help me.
Then I suggest you use a packet sniffer, such as Ethereal, to find out
exactly what the server is sending.
Gambit
Thanks Remy, |
Ive downloaded that and got it going. In the meantime I just put
the List() into a try/catch and allowed it to ingore the
return when there was an empty folder.
Now I can check the return and make it more specific.
Thanks for your help.
David |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|