예제 #1
0
        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);
        }
예제 #2
0
        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);
        }