private void _DirectoryMonitor_MonitoredFileRenamed(object sender, MonitoredFileRenamedArgs e) { try { //first find the file in the database var rawResult = m_database.Select <RawFileData>("FileCache", new DBPredicate("path", DBOperator.EQUALS, e.OldPath), new RawFileDataCreator()); if (rawResult == null) { //if it doesn't exist already, add it now int fileType = 0; int lastSlash = e.NewPath.LastIndexOf(@"\"); if (lastSlash == -1) { return; } if (File.Exists(e.NewPath)) { fileType = 1; } m_database.Insert <RawFileData>(DBCollisionAction.IGNORE, "FileCache", new RawFileData(-1, e.NewPath, e.NewPath.Substring(lastSlash + 1).ToLower(), fileType, null, 0, false, false)); } else { //if the file does exist in the database, update the old record int lastSlash = e.NewPath.LastIndexOf(@"\"); if (lastSlash == -1) { return; } List <DBPredicate> updateValues = new List <DBPredicate>(); updateValues.Add(new DBPredicate("path", DBOperator.EQUALS, e.NewPath)); updateValues.Add(new DBPredicate("name", DBOperator.EQUALS, e.NewPath.Substring(lastSlash + 1).ToLower())); m_database.Update("FileCache", updateValues, new DBPredicate("path", DBOperator.EQUALS, e.OldPath)); } } catch (Exception crap) { Settings.SessionLog += crap.Message + "\n"; Debug.WriteLine(crap.Message); } }