Check if file exists instead of catching exceptions

This commit is contained in:
Bond_009
2019-01-27 17:00:17 +01:00
parent 1a3543e5a5
commit ffe79c8982
6 changed files with 73 additions and 99 deletions

View File

@@ -246,14 +246,15 @@ namespace Emby.Server.Implementations.AppBase
private object LoadConfiguration(string path, Type configurationType)
{
if (!File.Exists(path))
{
return Activator.CreateInstance(configurationType);
}
try
{
return XmlSerializer.DeserializeFromFile(configurationType, path);
}
catch (FileNotFoundException)
{
return Activator.CreateInstance(configurationType);
}
catch (IOException)
{
return Activator.CreateInstance(configurationType);