Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.6k views
in Java FTP by (200 points)
I want to get dirDetails() for a given file (not the whole dir) but I encounter a problem if the file in question has a space in the filename.

If I have a file with space, for example "pic 1.jpg" (without quotes), the dirDetails() doesn't return any results for it. File "pic1.jpg" naturally works just fine. I've tried to escape the space and wrap the filename in single and double quotes, but nothing worked.

How can I get dirDetails() for a single file that has space in the name? Also worth mentioning that it's not an option to not have spaces in the filenames as that is not in my powers.

6 Answers

0 votes
by (162k points)
dirDetails() isn't intended to get details for single files. However depending on your FTP server, you may be able to use:

dirDetails("pic*1.jpg");

and if this is the only matching file, it might work for you.
0 votes
by (200 points)
Of course wildcard(s) works fine but that's not an option since it might bring up some problems later with filenames suchs as pic 1.jpg and pic21.jpg.

If dirDetails() isn't intended to get details for single files then what is? How do I get the size and modification date for a file without it? I mean it works just fine with files with no spaces in filenames, I can't see why the method's filename mask (no matter if it doesn't contain any wildcards) should screw up the space.
0 votes
by (200 points)
I researched it some more myself and the problem indeed seems to be with ftp server. It doesn't seem like spaces work with LIST command. With RETR spaces are ok (good thing so you can actually copy the files...). So there's nothing me or you can do about this. I think I'll just receive with wildcards and match the results to the known name and choose the one matching if there are several results.
0 votes
by (220 points)
Hi,
I am using edtftpj-pro-1.2.8 / SFTP and trying to get a list of files based on a filemask in a directory..
I do a chdir to set to the directory and do a client.dir("abc*.txt").
Even though there are files abc1.txt, abc2.txt in the directory , i get a No such file Exception..
Has anyone else seen this problem..
thanks
0 votes
by (162k points)
Not all FTP servers support the use of wildcards in directory listings - you may need to do a dir() and filter yourself on the client.

Hi,
I am using edtftpj-pro-1.2.8 / SFTP and trying to get a list of files based on a filemask in a directory..
I do a chdir to set to the directory and do a client.dir("abc*.txt").
Even though there are files abc1.txt, abc2.txt in the directory , i get a No such file Exception..
Has anyone else seen this problem..
thanks
0 votes
by (500 points)
I had the same issue with dirDetails() on remote folders. but only with IIS ftp server. I suggest to use "?" instead of "*": "?" matches exatcly one character not zero or more


clientFTP.dirDetails("/my?folder");

Categories

...