Getting the size of an audio file in ASP.NET

Given the sound file (mp3 or wav), can you get the duration, size (in bytes) and other file attributes here?

thank

+1
source share
4 answers

For file size FileInfo is worth a look

System.IO.FileInfo file = new System.IO.FileInfo(string filename);
long fileSize = file.Length;

This will give you the file size.

and get attributes like hidden status. something like the following can get it

  if (file.Attributes & System.IO.FileAttributes.Hidden == System.IO.FileAttributes.Hidden)
  {
       // hidden file
  }

In the second NAudio library to search for track duration [in seconds]

+1
source

You will need a library all the time. I just found this on google. http://www.codeplex.com/naudio

, System.IO.File. http://msdn.microsoft.com/en-us/library/system.io.file.aspx

0

, new FileInfo(path).Length.
, stream.Length.

, .

0

a++ SO , , .

mp3

Python, - , . , - , .

0

All Articles