Exemplo n.º 1
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.º 2
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.º 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
        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}");
        }