[Gambas-user] rdir returns unwanted directories

Tobias Boege taboege at ...626...
Sun May 28 19:29:13 CEST 2017


On Sun, 28 May 2017, Gianluigi wrote:
> Hi Tobias,
> if I have in my home a directory named image with a subfolder named
> my-image, containing both images, and I write:
> 
> Public Sub Main()
> 
>   Dim sFileArray As String[]
>   Dim s As String
>   Dim sPath As String = "~/image"
>   ' Run directory e sub-directory
>   sFileArray = RDir(sPath, "*.{png,jpg}", gb.File)
>   For Each s In sFileArray
>     Print s
>   Next
> 
> End
> 
> I obtain this:
> 
> my-image/actress.png
> my-image/alfa.jpg
> my-image/lamb.jpg
> snail.jpg
> horse.jpg
> oggy.png
> sparkle.png
> homer.jpg
> 
> 
> In the first three cases, to get the only file name, I need your suggestion.
> 
> Do not work so RDir to you?
> 

Oh, now the whole thread makes sense to me! I thought your problem was that
if you have a *directory* named "x.jpg" and issued

  RDir(..., "*.{png,jpg}", gb.File)

the gb.File filter was ignored and you were reported the directory "x.jpg",
because the "*.{png,jpg}" pattern matched. But you just wanted to get rid of
the directory component. Then you have your solution (use File.Name on s)
and there is no problem. Our RDir()s behave the same.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list