internal static SupportedFileFormat DetectFileSchema(string filePath) { if (!string.IsNullOrEmpty(filePath)) { if (filePath.EndsWith(SR.GetString("MainFrm_FileEtl"), StringComparison.OrdinalIgnoreCase)) { return(SupportedFileFormat.EtlBinary); } if (filePath.EndsWith(SR.GetString("PJ_Extension"), StringComparison.OrdinalIgnoreCase)) { return(SupportedFileFormat.STVProjectFile); } FileStream fileStream = null; char[] array = new char[8192]; try { fileStream = Utilities.CreateFileStreamHelper(filePath); Utilities.SeekFileStreamHelper(fileStream, 0L, SeekOrigin.Begin); Utilities.CreateStreamReaderHelper(fileStream).Read(array, 0, array.Length); } catch (IOException) { return(SupportedFileFormat.UnknownFormat); } finally { Utilities.CloseStreamWithoutException(fileStream, isFlushStream: false); } string text = new string(array); text = text.Trim(' ', '\0', '\t', '\n'); if (string.IsNullOrEmpty(text)) { return(SupportedFileFormat.E2ETraceEventSchema); } int num = text.IndexOf(crimsonSchemaTag, StringComparison.Ordinal); int num2 = text.IndexOf(e2eSchemaTag, StringComparison.Ordinal); if (num != -1 && num2 == -1) { return(SupportedFileFormat.CrimsonSchema); } if (num == -1 && num2 != -1) { return(SupportedFileFormat.E2ETraceEventSchema); } if (num != -1 && num2 == -1 && num < num2) { return(SupportedFileFormat.CrimsonSchema); } if (num != -1 && num2 == -1 && num > num2) { return(SupportedFileFormat.E2ETraceEventSchema); } } return(SupportedFileFormat.NotSupported); }