HI all, i wish save in a file.txt the chronology of the song played by my music Player . I tried this code snippet but doesn't work :
    StreamWriter sw = new StreamWriter(@"c:\Media PlayList\List.txt");
   private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        wmp.URL = Convert.ToString(listBox1.SelectedItem);
foreach (object o in listBox1.SelectedItems) 
         {
               sw.WriteLine(DateTime.Now + " - " + o.ToString());          
         }
    }
How i store songs :
private List<string> GetFolder(string Folder)
    {
        string filena;
        DirectoryInfo dir = new DirectoryInfo(Folder);
        FileInfo[] files = dir.GetFiles("*.mp3", SearchOption.AllDirectories);
        List<string> str = new List<string>();
        foreach (FileInfo file in files)
        {
            str.Add(file.FullName);    }
    }
private void Form2_Load(object sender, EventArgs e)
    {
       List<string> uno = GetFolder(@"D:\\Music\\");
        listBox1.DataSource = uno;
        listBox1.DisplayMember = "uno"; }
I need each time the Music Player change song the file "List.txt" will be update by listbox.SelectedItem but i cannot update the "List.txt" with my code. Where i wrong? Thanks for your attention.
Nice regards
EDIT: I updated my code snippet hoping it will be clear .