Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, so, I want get music file Properties on Datagridview and for that I am using Taglib Library. I can get Album, Genres, Artist, but I have Problem with it's Name.
tagFile.Name
returns Full Path of a File + it's name, for example:
"C://Desktop//Musics//musicName.mp3". All I want is just a name without Path. Who knows how to do that ?

What I have tried:

To get Name:
tagFile.Name

To get Album:
tagFile.Tag.Album;

To get Title:
tagFile.Tag.Title;
Posted
Updated 20-Aug-17 8:58am

1 solution

 
Share this answer
 
Comments
Thomas Daniels 20-Aug-17 15:28pm    
No, you need the static method GetFileNameWithoutExtension in the Path class in the System.IO namespace.
Thomas Daniels 20-Aug-17 15:29pm    
Like:

using System.IO; // put this at the top of your file

string path = tagFile.Name;
string result = Path.GetFileNameWithoutExtension(path);
Dave Kreskowiak 20-Aug-17 15:29pm    
That method has been in the .NET Framework since v1.1.

Did you import the System.IO namespace at the top of your code file?
dave_bulac 20-Aug-17 15:31pm    
yeap, I have done it, sorry I have writting not correctly.
What I had to write: string result = Path.GetFileNameWithoutExtension(path);
What I have written: string result = path.GetFileNameWithoutExtension(path);

Thank you for Help.
BillWoodruff 20-Aug-17 21:59pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900