Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C# Programming

C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-03-2007, 09:24 AM
Crane's Avatar   
Crane Crane is offline
Programming Expert
 
Join Date: Nov 2005
Posts: 399
Rep Power: 13
Crane is on a distinguished road
Default Getting File Name

I'm using a split function to get a the filename now but I think this will break if the depth of directories increase or decrease. Is there a way to get just the filename in a normal and safe manner?

I have

C:\test.txt

I want:

"test.txt"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-05-2007, 02:59 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,746
Last Blog:
Passwords
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
Send a message via AIM to John
Default

I know many languages have a basename function which does what you want. However, I'm not sure about C#. While you wait for someone who actually knows the answer, that might help you get started.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-06-2007, 09:25 AM
Jordan's Avatar   
Jordan Jordan is online now
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 26
Posts: 5,980
Last Blog:
SAP, ERP and EDI
Rep Power: 20
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

You will need to use the Path namespace:

Code:
Path.GetFileName(filePathVariable);
This will return "test.txt" as you mentioned above.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Don't hesitate to ask any questions that you have! Check out our ASCII Calculator!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-10-2007, 09:20 PM
icepack's Avatar   
icepack icepack is offline
Programmer
 
Join Date: Jul 2006
Location: North Carolina
Posts: 109
Rep Power: 8
icepack is on a distinguished road
Send a message via AIM to icepack
Default

funner to do in UNIX :-)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Project: ionFiles - Joomla Simple File Download Jordan Community Projects 302 08-30-2008 04:49 PM
File Manager Jaan Community Projects 45 08-27-2008 11:11 AM
Windows XP Tricks & Tips!!!!..new ones. pranky Tutorials 9 08-23-2008 03:22 PM
Project: ionFiles - Joomla Simple File Download - Mirror 2 Jordan ionFiles 3 04-07-2008 03:09 PM
text file manipulations in vb6.0 Ronin_paes Visual Basic Programming 3 06-11-2007 04:54 AM


All times are GMT -5. The time now is 09:48 AM.

Contest Stats

GoogleKeyw ........ 20.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 67%

Ads