Hello!
I'm experimenting with making a simple media player in Visual C# Express edition. I would like to know exacly how to open a directory and list only the .mp3 files or .ogg files in the listview I'm unsure how to do this. If you can point me to a good example or article, I would be very thankful.
Thank you.

search a directory
veh
hi,
what you asking about is System.IO name space it have directoryinfo and fileinfo classes that you can that, it will be something like that
using System.IO; namespace WindowsApplication1
{
//this form contain listbox and a button public partial class Form1 : Form {
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog ();
DialogResult reslt = fbd.ShowDialog();
if (reslt == DialogResult.OK)
{
GetSubFiles(fbd.SelectedPath);
}
}
private void GetSubFiles(string path)
{
//getting information about the root folder DirectoryInfo dirinf = new DirectoryInfo(path);
//retrieveing the files and folders from the root folder FileInfo[] Files = dirinf.GetFiles();
foreach (FileInfo File in Files)
{
if (File.Extension == ".mp3" || File.Extension == ".MP3")
{
listBox1.Items.Add(File.Name);
}
}
}
}
}
you can modify it , instead of adding directly to listbox you can use datatable and bindingsource
hope this helps
sa_andy
Thank you.