Exemplo n.º 1
0
        public static async Task <byte[]> LoadFileAsync(EPath type, string name)
        {
            var pathFile = Path.Combine(VehicleStartup.PathFiles, type.ToDescriptionString(), name);

            if (!File.Exists(pathFile))
            {
                return(null);
            }
            return(await File.ReadAllBytesAsync(pathFile));
        }
Exemplo n.º 2
0
        public static void Remove(EPath type, string name)
        {
            var pathFile = Path.Combine(VehicleStartup.PathFiles, type.ToDescriptionString(), name);

            if (!File.Exists(pathFile))
            {
                return;
            }
            File.Delete(pathFile);
        }
Exemplo n.º 3
0
        public static async Task SaveAsync(string base64, EPath type, string name)
        {
            var path = Path.Combine(VehicleStartup.PathFiles, type.ToDescriptionString());

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            var pathFile = Path.Combine(path, name);
            await File.WriteAllBytesAsync(pathFile, Convert.FromBase64String(base64.Split("base64,").Last()));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Check the system root folder in documents
        /// </summary>
        public EllyApplication()
        {
            epath = HelperFactory.GetModuleByType <EPath>();
            if (epath == null)
            {
                Debug.Log(GetInfo().ModuleName, "Cannot get EPath", Debug.DebugType.LogError);
                return;
            }

            InitializeFolder();
            ReadAppinfo();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Reading data from "document/data/language"
        /// And if there is no data in the folder, create a empty one.
        /// </summary>
        public override void OnLoad()
        {
            base.OnLoad();

            epath = HelperFactory.GetModuleByType <EPath>();
            if (epath == null)
            {
                Debug.Log(GetInfo().ModuleName, "Cannot get EPath", Debug.DebugType.LogError);
                return;
            }

            ReadAppLanguage();
        }
Exemplo n.º 6
0
        public static async Task <string> LoadBase64Async(EPath type, string name)
        {
            var pathFile = Path.Combine(VehicleStartup.PathFiles, type.ToDescriptionString(), name);

            if (!File.Exists(pathFile))
            {
                return(null);
            }
            var bytes = await File.ReadAllBytesAsync(pathFile);

            var base64 = Convert.ToBase64String(bytes);

            return($"data:{MimeUtility.GetMimeMapping(name)};base64,{base64}");
        }
Exemplo n.º 7
0
        /// <summary>
        /// writing message on end of target logging text file
        /// </summary>
        /// <param name="o"></param>
        private static void FileUpdate(string newLine)
        {
            EPath epath = HelperFactory.GetModuleByType <EPath>();

            /* Lastest */
            string[]      currentLastest  = File.ReadAllLines(Path.Combine(epath._ApplicationConfigPath(), EPath.ApplicationData, EPath.ApplicationLog, "Lastest log.txt"));
            List <string> _currentLastest = new List <string>(currentLastest);

            _currentLastest.Add(newLine);
            File.WriteAllLines(Path.Combine(epath._ApplicationConfigPath(), EPath.ApplicationData, EPath.ApplicationLog, "Lastest log.txt"), _currentLastest.ToArray());

            /* Datetime */
            if (File.Exists(Path.Combine(epath._ApplicationConfigPath(), EPath.ApplicationData, EPath.ApplicationLog, Filename)))
            {
                File.Delete(Path.Combine(epath._ApplicationConfigPath(), EPath.ApplicationData, EPath.ApplicationLog, Filename));
            }
            File.WriteAllLines(Path.Combine(epath._ApplicationConfigPath(), EPath.ApplicationData, EPath.ApplicationLog, Filename), Message);
        }