[Gambas-user] relative path

Stefano Palmeri rospolosco at ...152...
Sun Nov 15 17:23:26 CET 2009


Il domenica 15 novembre 2009 17:05:00 Charlie Reinl ha scritto:
> Am Sonntag, den 15.11.2009, 15:40 +0100 schrieb Stefano Palmeri:
> > Il domenica 15 novembre 2009 12:42:17 Charlie Reinl ha scritto:
> > > Salut,
> > >
> > > I looking for a function or switch in gambas,
> > > which gives me the path-string as relative path
> > > and not the whole path up from /
> >
> > I'm not sure I understood. Do you mean
> >
> > PRINT File.BaseName("/home/user/mydocuments")
> >
> > --> mydocuments
> >
> > ?
> >
> > Stefano
>
> Salut,
>
> I mean "/home/user/myNiceProject/allOtherFiles/ThisDoc.txt"
> to make "allOtherFiles/ThisDoc.txt"
>

DIM sFullPath, sRelativePath as string

sFullPath =  "/home/user/myNiceProject/allOtherFiles/ThisDoc.txt"

sRelativePath= File.BaseName(File.Dir(sFullPath)) &/ file.name(sFullPath)

PRINT sRelativePath

--> allOtherFiles/ThisDoc.txt

Saluti,

Stefano

> or "/home/user/mydocuments/allOtherFiles/ThisDoc.txt"
> out of "/home/user/myNiceProject" to make
> "../mydocuments/allOtherFiles/ThisDoc.txt"
>
> Hope that's clearer now!
>
> Even the "/home/user" replaced by "~" could be.
> But in a format, that all other functions which need a file as argument
> can handle it.






More information about the User mailing list