How to split path in c#
I have path of video like as C:\Users\Kalu\Desktop\Emptiness.mp4 . I want to get video name as Emptiness.mp4 in string. So how can i do.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Princy GuptaRank #1,602 · 982 reputationPosted Jun 10, 2014, 10:50 PM EDT
Hi
you can use the Path class available in System.IO namespace
string filename = Path.GetFileName(@"C:\Users\Kalu\Desktop\Emptiness.mp4");
if you need only filename without the extension use
filename = Path.GetFileNameWithoutExtension(@"C:\Users\Kalu\Desktop\Emptiness.mp4");
Hope it helps
kalu singh raoRank #884 · 2.4K reputationPosted Jun 10, 2014, 10:54 PM EDT