Getting file size from full file path and reading ID3 tags??

S

supster

I have the full file path of a file stored as a string and I'de like
to get the file size in bytes.

What is the most efficient way of doing this with a static method from
the File class or something like I've been using to move/copy files
around? I know this can be done by creating a FileInfo object, am I
wrong in thinking creating the object just to check the size is
unneccesary and unneficient?

I'de also like to read the ID3 tags of MP3 files, how can I go about
doing this?
 
J

Justin Rogers

If you are going to be reading ID3 tags then you need to open
the file anyway. The Length property of a FileStream should
work fine. If you are reading ID3v1 tags, these are quite easy
and they exist as the last 128 bytes in the file. You can read
out the requisite fields using a BinaryReader.


--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

supster said:
I have the full file path of a file stored as a string and I'de like
to get the file size in bytes.

What is the most efficient way of doing this with a static method from
the File class or something like I've been using to move/copy files
around? I know this can be done by creating a FileInfo object, am I
wrong in thinking creating the object just to check the size is
unneccesary and unneficient?

I'de also like to read the ID3 tags of MP3 files, how can I go about
doing this?
 
S

supster

I was actually hoping to avoid opening a stream to each file.

Looking around on google I found this:
http://www.thecodeproject.com/csharp/ShellID3TagReader.asp

Windows is able to display information read from ID3 tags when viewing
files in detailed list format, this seems to grab the information
that way.

This will read ID3v2 tags if available, if not ID3v1 tags. This seems
to be the best way to do it so I don't have to manually parse out the
data and fumble around checking if v1 or v2 tags exist. Any
thoughts?

Thanks
 
J

Justin Rogers

Explorer still opens the streams and then possibly caches the information
for future use. However, if you are looking for a generic V1/V2 solution
then yes, you probably want to use an OS service.


--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

supster said:
I was actually hoping to avoid opening a stream to each file.

Looking around on google I found this:
http://www.thecodeproject.com/csharp/ShellID3TagReader.asp

Windows is able to display information read from ID3 tags when viewing
files in detailed list format, this seems to grab the information
that way.

This will read ID3v2 tags if available, if not ID3v1 tags. This seems
to be the best way to do it so I don't have to manually parse out the
data and fumble around checking if v1 or v2 tags exist. Any
thoughts?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top