public void RefreshTranslationFiles(bool showDirNotFoundError = false) { TranslationFiles.Clear(); if (Directory.Exists(SelectedFolder)) { DirectoryInfo folder = new DirectoryInfo(SelectedFolder); FileInfo[] fileInfos = folder.GetFiles("*.json", SearchOption.TopDirectoryOnly); foreach (FileInfo translationFile in fileInfos) { StreamReader reader = new StreamReader(new FileStream(translationFile.FullName, FileMode.Open)); string jsonString = reader.ReadToEnd(); Dictionary <string, string> jsonPairs = JsonConvert.DeserializeObject <Dictionary <string, string> >(jsonString); ObservableCollection <TranslationPair> translationPairs = new ObservableCollection <TranslationPair>( jsonPairs.Select(pair => new TranslationPair { Key = pair.Key, Value = pair.Value })); string fileName = translationFile.Name.Substring(0, translationFile.Name.Length - translationFile.Extension.Length); TranslationFiles.Add(new TranslationFile { Name = fileName, Path = translationFile.FullName, TranslationPairs = translationPairs }); } RefreshScores(); _mainWindow.UpdateTabs(); } else { if (showDirNotFoundError) { MessageBox.Show("The selected folder wasn't found."); } } }