internal static String ReadToEndWithEncoding(String absoluteFilePath, out Encoding fileEncoding) { fileEncoding = EncodingUtil.GetFileEncoding(absoluteFilePath); StreamReader textFile = null; String fileContent; try { textFile = new StreamReader(absoluteFilePath, fileEncoding); fileContent = textFile.ReadToEnd(); } finally { if (textFile != null) { textFile.Close(); } } if (ConfigUtil.GetBoolParameter("IgnoreNullChar")) { fileContent = fileContent.Replace("\0", String.Empty); } return(fileContent); }
internal static Encoding GetTabTextEncoding(XtraTabPage tabPage) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage); Encoding fileEncoding; bool encodingForced = Convert.ToBoolean(pageTextBox.CustomEncodingForced); if ((encodingForced && !String.IsNullOrEmpty(pageTextBox.CustomEncoding)) || (EncodingUtil.IsEncodingDefaultEnabled() && !String.IsNullOrEmpty(pageTextBox.CustomEncoding))) { fileEncoding = Encoding.GetEncoding(Convert.ToInt32(pageTextBox.CustomEncoding)); } else { fileEncoding = EncodingUtil.GetDefaultEncoding(); } return(fileEncoding); }