Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split filename

Status
Not open for further replies.
Jan 20, 2005
65
GB
Is there a way to split a filename into its constituent parts with C#?
 
Do two split operations on it, using the Path.VolumeSeparatorChar and Path.DirectorySeparatorChar constants.

Note that the VolumeSeparatorChar won't help you for URL (file:///) or UNC (//server/share) paths. You'll have to special-case those.

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
How do you want to split it? Do you want the file from the extension? Or do you want the file apart from the folder, or the each part of the folder tree on it's own? Will your file path be static, or are you trying to create a general function that will do this for you?

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top