private void AddFile() { string filePath = testMode ? Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"../../../File Examples/file_example_1.mp3")) : GetFilePath_OpenDialog("mp3"); if (filePath != null && File.Exists(filePath) && !BasicFunctions.FileInUse(filePath)) { // check if File is already in list bool FileIsInList = false; foreach (MusicFileTag FileInList in MusicFileTags) { if (FileInList.FilePath == filePath) { FileIsInList = true; MessageBox.Show("This file is already in the list"); } } if (!FileIsInList) { MusicFileTag newFile = TaggingLogic.AddFile(filePath); MusicFileTags.Add(newFile); NumberOfFiles++; } } else { if (BasicFunctions.FileInUse(filePath)) { MessageBox.Show("Sorry, this file cannot be opened. " + "Either it is currently in use or this program does not have the necessary rights to read the file."); } } }
private void RemoveFile() { MusicFileTags.Remove(SelectedFile); NumberOfFiles--; }