diff --git a/SabreTools.Library/IO/FileExtensions.cs b/SabreTools.Library/IO/FileExtensions.cs index 39cf9043..429ee9fe 100644 --- a/SabreTools.Library/IO/FileExtensions.cs +++ b/SabreTools.Library/IO/FileExtensions.cs @@ -203,9 +203,13 @@ namespace SabreTools.Library.IO /// http://stackoverflow.com/questions/3825390/effective-way-to-find-any-files-encoding public static Encoding GetEncoding(string filename) { + // Try to open the file + FileStream file = TryOpenRead(filename); + if (file == null) + return Encoding.Default; + // Read the BOM var bom = new byte[4]; - FileStream file = FileExtensions.TryOpenRead(filename); file.Read(bom, 0, 4); file.Dispose();