Click here to Skip to main content
15,071,713 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi, I am using ASP.NET and C#.NET 2.0. I am showing all the mp3 files of a folder called "Sandler" in a gridview. I want to display the duration of each mp3 file in the gridview. I tried but I didn't get the solution.

Here is my code:
public void GetSandlerTrainingFiles()
{ 

String FileName="";
string[] filePaths = System.IO.Directory.GetFiles(Server.MapPath("sandler"/));

             List<listitem> files = new List<listitem>();
            foreach (string filePath in filePaths)
            {
                string p = filePath;
                string fileExt=Path.GetExtension(p);
                if (fileExt == ".mp3")
                {
                    files.Add(new ListItem(Path.GetFileName(filePath), filePath));
                }
            }


            dgrid_sandlertraining.DataSource = files;
            dgrid_sandlertraining.DataBind();
}

Now I want to display audio file duration in gridview. This is to be done only in .NET 2.0.

Please help me.

Thanks
Srinivas D
Posted
Updated 13-Mar-13 7:17am
v3

1 solution

I have had issues with Windows calculating the duration incorrectly - especially if they are VBR.
I use UltraId3[^] to read the meta data as that is usually more accurate.
   

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