//Select File Name private void Button_MenuItem_fileName_Click(object sender, RoutedEventArgs e) { //Get the Click Item var item = e.OriginalSource as System.Windows.Controls.MenuItem; //Get Storage File string StorageFile = item.Tag.ToString(); //Read Sheets Names from the File string FilePath = System.IO.File.ReadAllText(StorageFile); //Check if file exists bool bExists = File.Exists(FilePath); //Print file in case it is found if (bExists == true) { ////Print Excel File Name PrintFileName(FilePath); } else { //Get the File Name string FileName = Path.GetFileNameWithoutExtension(FilePath); //Delete in case it is not found DesignUtils.DeleteStorageTextFileRun(FileName); //Error Message MessageBox.Show($"File '{FileName}' was not found and deleted from the list", "Select File", MessageBoxButton.OK, MessageBoxImage.Error); } }