[Gambas-user] rdir returns unwanted directories

Gianluigi bagonergi at ...626...
Sun May 28 19:22:38 CEST 2017


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?

Regards
Gianluigi

2017-05-28 17:40 GMT+02:00 Tobias Boege <taboege at ...626...>:

> On Sun, 28 May 2017, Charlie wrote:
> > I presume you just want the file name not the folder details. If so try
> this,
> > sFiles will contain just the file name: -
> > *Public Sub Form_Open()
> > Dim sFileArray As New String[]
> > Dim sFiles As New String[]
> > Dim sTemp As String
> > sFileArray = RDir(User.Home, "*", gb.File)
> > For Each sTemp In sFileArray
> >   sFiles.Add(Mid(sTemp, RInStr(sTemp, "/") + 1))
> > Next
> > End*
>
> Instead of Mid(sTemp, RInStr(sTemp, "/") + 1) you may want to use the
> appropriately named function File.Name(sTemp).
>
> Still, using RDir(..., "*", gb.File) only gives me files, no directories,
> so I can't reproduce your original problem here.
>
> Regards,
> Tobi
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list