Exemple #1
0
        public bool LoadIni(string filename)
        {
            FileStream fs = File.Open(filename, FileMode.Open);

            _ini = new byte[fs.Length];
            fs.Read(_ini, 0, _ini.Length);
            fs.Close();

            if (Useful.IsUTF8(_ini))
            {
                return(true);
            }
            else
            {
                _ini = null;
                return(false);
            }
        }
Exemple #2
0
        public static bool UTF8Validator(string filename)
        {
            Cll.Log.WriteLine("The UTF8 validator will be used, it is not 100% reliable.");

            bool result = false;

            if (File.Exists(filename))
            {
                FileStream fs = null;
                try
                {
                    fs = File.Open(filename, FileMode.Open);
                    byte[] file = new byte[fs.Length];
                    fs.Read(file, 0, file.Length);
                    fs.Close();
                    if (Useful.IsUTF8(file))
                    {
                        Cll.Log.WriteLine("The file \"" + filename + "\" is valid!");
                        result = true;
                    }
                }
                catch (Exception e)
                {
                    Cll.Log.WriteLine("The file \"" + filename + "\" is invalid.\n" + e.Message);
                }
                finally
                {
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }
            }
            else
            {
                Console.WriteLine("The file \"" + filename + "\" not exists.");
            }

            return(result);
        }