The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
File Name From Path...
Discuss File Name From Path... in the C Programming forum on Dev Shed. File Name From Path... C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 9th, 2004, 08:48 PM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
File Name From Path...
Hi,
Is there a function for getting only the file name from a full Windows path? I seem to have this vague memory of one but can't remember it.
Thanks,
Nat Ryall.
|

September 10th, 2004, 10:45 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Location: Zagreb, Croatia
Posts: 15
Time spent in forums: 1 h 57 m 10 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by BLiND_LiMiT Hi,
...the file name from a full Windows path?...
|
Try this. Maybe, not the best way to do it, but you can start from that and build your own.
|

September 10th, 2004, 10:47 AM
|
 |
Contributing User
|
|
Join Date: Jan 2004
Location: near St. Louis Illinois
|
|
|
its very simple to do youself -- just look for the last '\' (or '/' in *nix) and the remainder of the string is the filename. Calling a function to do that is sort of a waste of time.
|

September 10th, 2004, 06:03 PM
|
 |
Business Analyst
|
|
Join Date: Mar 2004
Location: The 'Ville
|
|
CString.ReverseFind("\\");
This can be used in combination with CString.Delete() to delete from 0 to whatever index ReverseFind returns. That will leave only the file name and its file type extension.
For instance:
"C:\somedirectory\somesubdirectory\somefile.txt"
ReverseFind("\\") would return 35 (the index of the last \).
Then Delete(0, 35) leaves just "somefile.txt"
__________________
Discontent is the first necessity of progress. - Edison
Last edited by mateoc15 : September 10th, 2004 at 06:38 PM.
|

September 10th, 2004, 06:13 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|

September 11th, 2004, 05:42 AM
|
|
Contributing User
|
|
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,200
  
Time spent in forums: 1 Week 1 Day 11 h 47 m 52 sec
Reputation Power: 12
|
|
|
man basename dirname
also interesting
man realpath resolvepath
|

September 11th, 2004, 10:25 AM
|
 |
Business Analyst
|
|
Join Date: Mar 2004
Location: The 'Ville
|
|
Quote: | Originally Posted by guggach man basename dirname
also interesting
man realpath resolvepath |
guggach = "the *nix Nazi"...
hehe, you offered a reply to a question of mine a few days ago, I'm not familiar w/ *nix C/C++ at all, but rock on...
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|