C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 9th, 2004, 08:48 PM
BLiND_LiMiT BLiND_LiMiT is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 11 BLiND_LiMiT User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to BLiND_LiMiT Send a message via AIM to BLiND_LiMiT
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.

Reply With Quote
  #2  
Old September 10th, 2004, 10:45 AM
Delf Delf is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Zagreb, Croatia
Posts: 15 Delf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #3  
Old September 10th, 2004, 10:47 AM
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jan 2004
Location: near St. Louis Illinois
Posts: 3,288 Ancient Dragon User rank is Sergeant (500 - 2000 Reputation Level)Ancient Dragon User rank is Sergeant (500 - 2000 Reputation Level)Ancient Dragon User rank is Sergeant (500 - 2000 Reputation Level)Ancient Dragon User rank is Sergeant (500 - 2000 Reputation Level)Ancient Dragon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 20 h 37 m 22 sec
Reputation Power: 23
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.

Reply With Quote
  #4  
Old September 10th, 2004, 06:03 PM
mateoc15's Avatar
mateoc15 mateoc15 is offline
Business Analyst
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2004
Location: The 'Ville
Posts: 1,087 mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 19 h 17 m 11 sec
Reputation Power: 21
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.

Reply With Quote
  #5  
Old September 10th, 2004, 06:13 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,390 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 22 h 32 m 40 sec
Reputation Power: 4080
__________________
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

Reply With Quote
  #6  
Old September 11th, 2004, 05:42 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,200 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
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

Reply With Quote
  #7  
Old September 11th, 2004, 10:25 AM
mateoc15's Avatar
mateoc15 mateoc15 is offline
Business Analyst
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2004
Location: The 'Ville
Posts: 1,087 mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 19 h 17 m 11 sec
Reputation Power: 21
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...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > File Name From Path...

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap