| View previous topic :: View next topic |
| Author |
Message |
LarryJ Guest
|
Posted: Thu Oct 13, 2005 5:58 pm Post subject: removing file extension |
|
|
Is there an API that will remove the file extension from a file name, and
return only the file name?
Thanks
Larry Johnson.
|
|
| Back to top |
|
 |
LarryJ Guest
|
Posted: Thu Oct 13, 2005 6:35 pm Post subject: Re: removing file extension |
|
|
I changed the extension to "" and that worked to return just the file name.
Thanks.
"Hans Galema" <notused (AT) notused (DOT) nl> wrote
| Quote: |
Have a look at ChangeFileExt().
|
|
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Thu Oct 13, 2005 7:08 pm Post subject: Re: removing file extension |
|
|
| Quote: | Have a look at ChangeFileExt().
|
Heh :)
I made 'my' own routine for that long time ago,
and I never thought that I could accomplish that
easier with ChangeFileExt(), although I use it
every day...
AnsiString ExtractFileNameWithoutExtension( AnsiString FILE )
{
/* MY OLD CODE
AnsiString FNM = ExtractFileName( FILE );
AnsiString EXT = ExtractFileExt ( FNM );
FNM.SetLength( FNM.Length() - EXT.Length() );
return ( FNM );
*/
return ( ExtractFileName ( ChangeFileExt( FILE, "" ) ) );
}
--
Best regards,
Vladimir Stefanovic
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Thu Oct 13, 2005 9:47 pm Post subject: Re: removing file extension |
|
|
Vladimir Stefanovic wrote:
| Quote: | ... I never thought that I could accomplish that
easier with ChangeFileExt(), although I use it
every day...
AnsiString ExtractFileNameWithoutExtension( AnsiString FILE )
{
return ( ExtractFileName ( ChangeFileExt( FILE, "" ) ) );
}
|
But there is more.
#include <stdio.h>
FILE *fopen(const char *filename, const char *mode);
FILE is already defined for decades. Moreover you mean a path.
AnsiString ExtractFileNameWithoutExtension( AnsiString Path );
Hans.
|
|
| Back to top |
|
 |
|