ID3.NET FAQ

Why is everything so Stream-based and why can't I use files directly?

The ID3.NET core library is a portable class library that supports a variety of .NET platforms, namely .NET 4 and higher, Silverlight 4 and higher, Windows Phone 7.1 and .NET for Metro-style apps. As such, it misses out on a few features provided by the full .NET Framework, notably file handling.
This is why the core library uses only Stream-derived classes to load MP3 files.

You can still use the FileStream class to load MP3 files using the core library:
var fs = new FileStream(@"C:\Music\Song.mp3", FileMode.Open, FileAccess.Read);
var mp3 = new Mp3Stream(fs);

The ID3.Files assembly

If you want to open MP3 files without having to deal with file streams, you can use the ID3.Files assembly, which is a full .NET Framework library and provides the ability to open and save MP3 files directly.
The ID3.Files assembly provides a class called Mp3File that derives from the core's Mp3Stream class and adds new constructors to load MP3 files by specifying the file name or the FileInfo object representing the file. Internally, these constructors create a FileStream instance with the appropriate permissions.

//Open MP3 file in read-only permissions
var mp3 = new Mp3File(@"C:\Music\Song.mp3");

//Open MP3 file with read/write permissions
var mp3 = new Mp3File(@"C:\Music\Song.mp3", Mp3Permissions.ReadWrite);

Last edited Aug 17, 2012 at 11:34 AM by jeevanjj, version 1

Comments

No comments yet.