Skip to content

Commit

Permalink
Exception handled at traversing filenames for a media folder
Browse files Browse the repository at this point in the history
  • Loading branch information
DineshSolanki committed Aug 5, 2021
1 parent 317aacf commit 61ab94f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 4 deletions.
4 changes: 4 additions & 0 deletions FoliCon/Modules/LangProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private void UpdateLangs()
OnPropertyChanged(nameof(UsePosterOverlay));
OnPropertyChanged(nameof(Version));
OnPropertyChanged(nameof(Year));
OnPropertyChanged(nameof(ExceptionOccurred));
}

public string About => Lang.About;
Expand Down Expand Up @@ -410,6 +411,7 @@ private void UpdateLangs()
public string Version => Lang.Version;

public string Year => Lang.Year;
public string ExceptionOccurred => Lang.ExceptionOccurred;


public event PropertyChangedEventHandler PropertyChanged;
Expand Down Expand Up @@ -668,5 +670,7 @@ public class LangKeys

public static string Year = nameof(Year);

public static string ExceptionOccurred = nameof(ExceptionOccurred);

}
}
13 changes: 10 additions & 3 deletions FoliCon/Modules/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ public static List<string> GetFolderNames(string folderPath)
where !File.Exists(folder + @"\" + Path.GetFileName(folder) + ".ico")
select Path.GetFileName(folder));
}

return folderNames;
}

Expand Down Expand Up @@ -315,8 +314,16 @@ public static ObservableCollection<ListItem> FetchAndAddDetailsToListView(Result
public static List<string> GetFileNamesFromFolder(string folder)
{
var itemList = new List<string>();
if (string.IsNullOrEmpty(folder)) return itemList;
itemList.AddRange(Directory.GetFiles(folder).Select(Path.GetFileName));
try
{
if (string.IsNullOrEmpty(folder)) return itemList;
itemList.AddRange(Directory.GetFiles(folder).Select(Path.GetFileName));
}
catch (Exception e)
{
itemList.Add($"Error accessing files: {e.Message}");
}

return itemList;
}

Expand Down
9 changes: 9 additions & 0 deletions FoliCon/Properties/Langs/Lang.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions FoliCon/Properties/Langs/Lang.ar.resx
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,7 @@
<data name="Version" xml:space="preserve">
<value>إصدار :</value>
</data>
<data name="ExceptionOccurred" xml:space="preserve">
<value>حدث استثناء</value>
</data>
</root>
3 changes: 3 additions & 0 deletions FoliCon/Properties/Langs/Lang.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,7 @@ y puede buscar "Juegos, películas y programas" y casi cualquier ícono de carpe
<data name="Version" xml:space="preserve">
<value>Versión :</value>
</data>
<data name="ExceptionOccurred" xml:space="preserve">
<value>Ocurrió una excepción</value>
</data>
</root>
3 changes: 3 additions & 0 deletions FoliCon/Properties/Langs/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@
<data name="EnterTitlePlaceholder" xml:space="preserve">
<value>Please Enter Title here to search again.</value>
</data>
<data name="ExceptionOccurred" xml:space="preserve">
<value>Exception Occurred</value>
</data>
<data name="Folder" xml:space="preserve">
<value>Folder</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions FoliCon/Properties/Langs/Lang.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,7 @@
<data name="Version" xml:space="preserve">
<value>Версия:</value>
</data>
<data name="ExceptionOccurred" xml:space="preserve">
<value>Произошло исключение</value>
</data>
</root>
2 changes: 1 addition & 1 deletion FoliCon/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private async void SearchAndMakeMethod()
}
catch (Exception e)
{
MessageBox.Show(CustomMessageBox.Error(e.Message, "Exception Occurred"));
MessageBox.Show(CustomMessageBox.Error(e.Message, LangProvider.GetLang("ExceptionOccurred")));
StatusBarProperties.ResetData();
IsMakeEnabled = true;
}
Expand Down

0 comments on commit 61ab94f

Please sign in to comment.