BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

removing file extension

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
LarryJ
Guest





PostPosted: Thu Oct 13, 2005 5:58 pm    Post subject: removing file extension Reply with quote



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





PostPosted: Thu Oct 13, 2005 6:35 pm    Post subject: Re: removing file extension Reply with quote



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





PostPosted: Thu Oct 13, 2005 7:08 pm    Post subject: Re: removing file extension Reply with quote



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





PostPosted: Thu Oct 13, 2005 9:47 pm    Post subject: Re: removing file extension Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.