public async Task ClearPlaylist()
 {
     if (await _storageService.FileExistsAsync(_playlistFile))
     {
         await _storageService.DeleteFileAsync(_playlistFile);
     }
 }
예제 #2
0
        private static async Task <string> GetLogFileContent()
        {
            try
            {
                if (await CacheStorage.FileExistsAsync(LogFileName))
                {
                    return(await CacheStorage.ReadAllTextAsync(LogFileName));
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(null);
        }
 public static async Task DeleteFileIfExists(this IStorageServiceHandler storageService, string file)
 {
     if (await storageService.FileExistsAsync(file))
     {
         await storageService.DeleteFileAsync(file);
     }
 }
        public async Task <bool> HasImage(string itemId, string imageId)
        {
            var itemCacheFolder = GetItemCachePath(itemId);

            var imageFile = GetItemImagePath(itemCacheFolder, imageId);

            return(await _storageService.FileExistsAsync(imageFile));
        }
        public static async Task <string> ReadStringIfFileExists(this IStorageServiceHandler storageService, string file)
        {
            if (!await storageService.FileExistsAsync(file))
            {
                return(string.Empty);
            }

            return(await storageService.ReadAllTextAsync(file));
        }
        public static async Task <Stream> OpenFileIfExists(this IStorageServiceHandler storageService, string file)
        {
            if (await storageService.FileExistsAsync(file))
            {
                return(await storageService.OpenFileForReadAsync(file));
            }

            return(null);
        }
 public static async Task MoveFileIfExists(this IStorageServiceHandler storageService, string source, string destination, bool overwrite)
 {
     if (await storageService.FileExistsAsync(source))
     {
         var destinationFolder = Path.GetDirectoryName(destination);
         if (!await storageService.DirectoryExistsAsync(destinationFolder))
         {
             await storageService.CreateDirectoryAsync(destinationFolder);
         }
         await storageService.MoveFileAsync(source, destination, overwrite);
     }
 }
예제 #8
0
        private async Task SaveTheImage(WriteableBitmap bitmap, string filename)
        {
            if (await _storageService.FileExistsAsync(filename))
            {
                await _storageService.DeleteFileAsync(filename);
            }

            using (var fileStream = await _storageService.CreateFileAsync(filename))
            {
                await bitmap.SavePngAsync(fileStream);
            }
        }
예제 #9
0
 public async Task <bool> FileExists(string path)
 {
     try
     {
         path = AnyTimePath(path);
         return(await _storageService.FileExistsAsync(path));
     }
     catch
     {
         return(false);
     }
 }
        private async Task SaveTheImage(WriteableBitmap bitmap)
        {
            if (await _storageService.FileExistsAsync(LockScreenFile))
            {
                await _storageService.DeleteFileAsync(LockScreenFile);
            }

            using (var fileStream = await _storageService.CreateFileAsync(LockScreenFile))
            {
                var encoder = new PngEncoder();
                var image   = bitmap.ToImage();
                encoder.Encode(image, fileStream);
            }
        }
        public async Task <ServerCredentials> GetServerCredentials()
        {
            if (!await _storageService.FileExistsAsync(Constants.Settings.ServerCredentialSettings))
            {
                return(new ServerCredentials());
            }

            var json = await _storageService.ReadAllTextAsync(Constants.Settings.ServerCredentialSettings);

            var credentials = JsonConvert.DeserializeObject <ServerCredentials>(json);

            Debug.WriteLine("GetCreds, Server count: " + (credentials != null && credentials.Servers != null ? credentials.Servers.Count : 0));

            return(credentials ?? new ServerCredentials());
        }