|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace ShellID3Reader
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBoxFilePath;
private System.Windows.Forms.Button cmdBrowseForFolder;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button cmdReadTags;
private System.Windows.Forms.ListView listViewFiles;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public frmMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxFilePath = new System.Windows.Forms.TextBox();
this.cmdBrowseForFolder = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.cmdReadTags = new System.Windows.Forms.Button();
this.listViewFiles = new System.Windows.Forms.ListView();
this.folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
this.SuspendLayout();
//
// textBoxFilePath
//
this.textBoxFilePath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxFilePath.Location = new System.Drawing.Point(8, 28);
this.textBoxFilePath.Name = "textBoxFilePath";
this.textBoxFilePath.Size = new System.Drawing.Size(592, 20);
this.textBoxFilePath.TabIndex = 0;
this.textBoxFilePath.Text = "Select a folder ....";
//
// cmdBrowseForFolder
//
this.cmdBrowseForFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cmdBrowseForFolder.Location = new System.Drawing.Point(608, 24);
this.cmdBrowseForFolder.Name = "cmdBrowseForFolder";
this.cmdBrowseForFolder.Size = new System.Drawing.Size(56, 24);
this.cmdBrowseForFolder.TabIndex = 1;
this.cmdBrowseForFolder.Text = "...";
this.cmdBrowseForFolder.Click += new System.EventHandler(this.cmdBrowseForFolder_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(592, 16);
this.label1.TabIndex = 2;
this.label1.Text = "Folder Path :";
//
// cmdReadTags
//
this.cmdReadTags.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cmdReadTags.Location = new System.Drawing.Point(520, 56);
this.cmdReadTags.Name = "cmdReadTags";
this.cmdReadTags.Size = new System.Drawing.Size(144, 24);
this.cmdReadTags.TabIndex = 3;
this.cmdReadTags.Text = "&Read Tags";
this.cmdReadTags.Click += new System.EventHandler(this.cmdReadTags_Click);
//
// listViewFiles
//
this.listViewFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewFiles.Location = new System.Drawing.Point(8, 88);
this.listViewFiles.Name = "listViewFiles";
this.listViewFiles.Size = new System.Drawing.Size(656, 384);
this.listViewFiles.TabIndex = 4;
this.listViewFiles.View = System.Windows.Forms.View.Details;
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(672, 478);
this.Controls.Add(this.listViewFiles);
this.Controls.Add(this.cmdReadTags);
this.Controls.Add(this.label1);
this.Controls.Add(this.cmdBrowseForFolder);
this.Controls.Add(this.textBoxFilePath);
this.Name = "frmMain";
this.Text = "Read ID3 tags using Shell functions";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
}
private void cmdBrowseForFolder_Click(object sender, System.EventArgs e) {
try{
folderBrowserDialog.ShowDialog();
textBoxFilePath.Text = folderBrowserDialog.SelectedPath;
}
catch{}
}
private void cmdReadTags_Click(object sender, System.EventArgs e) {
listViewFiles.Columns.Clear();
listViewFiles.Items.Clear();
listViewFiles.Columns.Add("FileName",100,HorizontalAlignment.Left);
listViewFiles.Columns.Add("ArtistName",100,HorizontalAlignment.Left);
listViewFiles.Columns.Add("AlbumName",100,HorizontalAlignment.Left);
listViewFiles.Columns.Add("TrackNumber",100,HorizontalAlignment.Left);
listViewFiles.Columns.Add("SongTitle",100,HorizontalAlignment.Left);
DirectoryInfo dir = new DirectoryInfo(textBoxFilePath.Text);
FileInfo[] files = dir.GetFiles("*.mp3");
foreach(FileInfo fi in files){
MP3File mp3File = ShellID3TagReader.ReadID3Tags(fi.FullName);
ListViewItem itm = new ListViewItem();
itm.Text = mp3File.FileName;
itm.SubItems.Add(mp3File.ArtistName);
itm.SubItems.Add(mp3File.AlbumName );
itm.SubItems.Add(mp3File.TrackNumber.ToString()) ;
itm.SubItems.Add(mp3File.SongTitle);
listViewFiles.Items.Add(itm);
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.