Page 1 of 1

dirlist function

Posted: January 20th, 2021, 8:58 am
by AriSilva
The function returns a full qualified name, such as
/storage/emulated/0/data/gov.census..........................
Is there a way to get only the filename (with or without) the extension?
I´m trying to deal with a bunch of files in a certain directory, but it is a little bit difficult with the complete name.

Re: dirlist function

Posted: January 20th, 2021, 9:14 am
by josh
In CSPro 7.5 you can use path.GetFileName() or path.GetFilenameWithoutExtension() to get just the filename. In earlier versions you had to write your own versions of those functions that would search backwards through the string to get the last "/".

Re: dirlist function

Posted: January 24th, 2021, 8:54 am
by AriSilva
Thanks Josh, I did not know about these functions.
I was looking at the alphabetical list of functions and just did not see the use for them there (my fault).
Now, by looking at the what´s new in 7.5 I realize my mistake.
Next time I´ll pay more attention to that.