diff --git a/GUI/ViewModel.cs b/GUI/ViewModel.cs index 10dc8690..408f8c56 100644 --- a/GUI/ViewModel.cs +++ b/GUI/ViewModel.cs @@ -78,10 +78,23 @@ namespace GARbro.GUI public EntryViewModel (Entry entry, int priority) { Source = entry; - Name = Path.GetFileName (entry.Name); + Name = SafeGetFileName (entry.Name); Priority = priority; } + static char[] SeparatorCharacters = { '\\', '/', ':' }; + + /// + /// Same as Path.GetFileName, but ignores invalid charactes + /// + string SafeGetFileName (string filename) + { + var name_start = filename.LastIndexOfAny (SeparatorCharacters); + if (-1 == name_start) + return filename; + return filename.Substring (name_start+1); + } + public event PropertyChangedEventHandler PropertyChanged; public Entry Source { get; private set; }