Hi there,
I forgot the names of some file functions....
I have eg. C:\path1\path2\filename.ext and I need :
Path -->C:\path1\path2
Filename (wo extension) -->filename
Extension ->EXT
Which function can help me?
Serge
Extracting path and file name and extension
Moderator: Rathinagiri
- serge_girard
- Posts: 3309
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Extracting path and file name and extension
There's nothing you can do that can't be done...
Re: Extracting path and file name and extension
Hey Serge,serge_girard wrote: ↑Sat Jun 17, 2023 4:25 pm Hi there,
I forgot the names of some file functions....
I have eg. C:\path1\path2\filename.ext and I need :
Path -->C:\path1\path2
Filename (wo extension) -->filename
Extension ->EXT
Which function can help me?
Try the following useful functions:

Code: Select all
*-----------------------------------------------------------------------------*
FUNCTION cFilePath ( cPathMask )
*-----------------------------------------------------------------------------*
LOCAL cPath
hb_FNameSplit ( cPathMask, @cPath )
RETURN hb_StrShrink( cPath )
*-----------------------------------------------------------------------------*
FUNCTION cFileName ( cPathMask )
*-----------------------------------------------------------------------------*
LOCAL cName
hb_FNameSplit ( cPathMask, , @cName )
RETURN ( cName )
*-----------------------------------------------------------------------------*
FUNCTION cFileExt ( cPathMask )
*-----------------------------------------------------------------------------*
LOCAL cExt
hb_FNameSplit ( cPathMask, , , @cExt )
RETURN cExt
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Re: Extracting path and file name and extension
Look at https://github.com/Petewg/harbour-core/wiki/File-IO
hb_FNameDir(<cFileName>)
hb_FNameExt(<cFileName>)
hb_FNameName(<cFileName>)
hb_FNameNameExt(<cFileName>)
hb_FNameSplit(<cFileName>, [@cFullPathWithDrive], [@cName], [@cExt], [@cDriveLetter])
hb_FNameDir(<cFileName>)
hb_FNameExt(<cFileName>)
hb_FNameName(<cFileName>)
hb_FNameNameExt(<cFileName>)
hb_FNameSplit(<cFileName>, [@cFullPathWithDrive], [@cName], [@cExt], [@cDriveLetter])
- serge_girard
- Posts: 3309
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Extracting path and file name and extension
Thanks Edward+Grigory !
Serge
Serge
There's nothing you can do that can't be done...