Subject Re: Getting Just the File Name from Getfile()
From Andy Taylor <andy.taylor@which.net>
Date Wed, 23 May 2018 04:36:40 -0400
Newsgroups dbase.getting-started

Louis,

I see you already have good answers.
I've added the below to show that if you wrap stuff like this up into a function you never have to
remember how to do it or re-invent the wheel.
The following is cut and pasted from a "procedure file" within my own library code.

function getFileName(cFilePath)
   // Returns the filename from a passed full file path
   return substr(cFilePath,rat("\",cFilePath)+1)

As long as your function is in scope (see 'set procedure' in the OLH) your code can just be:

f  = getFileName(GETFILE("*Z*.xml","Select a File",.T.,"XML Files (*.xml)"))

Andy

> Firstly assume that I am in the folder F:\Data\2018\03-2018
>
> if I use getfile(), in the following example:
>
>      f  = GETFILE("*Z*.xml","Select a File",.T.,"XML Files (*.xml)")
>
> I will get on the return something like:
>
> f = F:\Data\2018\03-2018\04-23-2018 The Long FileName.xml
>
> What I am interested in is JUST the filename without the path.  In this example:
>
> 04-23-2018 The LongFileName.xml
>
> How do I strip out the path and just get the filename.  Thank you for helping.
>
> Louis