how to determine if a object dir or file is? (wodSFTP / wodSFTP.NET / wodSFTPdll)
Hello,
I have now a list of objects created with
ListNames() method.
I must know, if a list member dir or file is.
So, I check an exception:
try
{
bDir = false;
if(!pFtpCom->CheckDir(lpTestDir))
{
bDir = true;
}
} catch(...){pFtpCom->PutLastError(0);};
if(!bDir)
try
{
pFtpCom->GetFile(vLclDir,name);
}
catch(...)
{
pFtpCom->get_LastError(&LastError);
_bstr_t err = pFtpCom->GetErrorText(LastError);
printf( ( d ) s
,LastError,(LPSTR)err);
pFtpCom->PutLastError(0);
}
}
It works with error:
If the first item found is a dir, and the next one a file,
it will be the next exception thrown. It should not!
If the first item found is a file, it will be get without any exception.
Is there any other workaround, how to determine if an list item
dir or file is?
Thanks
Jan
[:wink:]
Re: how to determine if a object dir or file is?
Jan,
why don't you use DirItems.Type property for this?
Re: how to determine if a object dir or file is?
why don't you use DirItems.Type property for this?
In order to access this property, I must call ListDir method first .
I do not call ListDir.
I call ListNames.
As a target I get a list of files and dirs.
So, I must reject all dir from this list.
As a rejecting result it left only some files, I can download.
It is a pitty there is not any method ListAllFilesInDir
Thanks
Jan
[:sad:]
Re: how to determine if a object dir or file is?
Jan,
there can be no methods to list only files. This all depends on FTP protocol and what will server send us, we cannot create new commands and violate the protocol. You can use ListDir and perhaps set different ListParams that will cause your server to send only file names. But as I said - this all depends on the server.
Re: how to determine if a object dir or file is?
Hello,
So, is there any simple method to get a type of file/dir?
If I have to names:
name1 // file
name2 // directory
get by ListNames.
How do I know what of them is dir/file ?
Many thanks!
Jan
[:smile:]
Re: how to determine if a object dir or file is?
You cannot. Servers will usually add / at the end of dir, but this isn't true in all 100 cases.