// Method used by OnCreated / OncHanged to add / update the song structure private static void AddUpdateSong(string strFileName) { if (musicDB.SongExists(strFileName)) { musicDB.UpdateSong(strFileName); return; } // For some reason the Create is fired already by windows while the file is still copied. // This happens especially on large songs copied via WLAN. // The result is that MP Readtag is throwing an IO Exception. // I'm trying to open the file here and in case of an exception i'll put it on a thread to be // processed 5 seconds later again. try { FileInfo file = new FileInfo(strFileName); Stream s = null; s = file.OpenRead(); s.Close(); } catch (IOException) { // The file is not closed yet. Ignore the event, it will be processed by the Change event return; } musicDB.AddSong(strFileName); // Check for Various Artists //musicDB.CheckVariousArtists(song.Album); }