Skip to content

Instantly share code, notes, and snippets.

@Delaire
Last active August 2, 2018 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Delaire/7789ccad1a9a7caf89f847fbdbeb3ea6 to your computer and use it in GitHub Desktop.
Save Delaire/7789ccad1a9a7caf89f847fbdbeb3ea6 to your computer and use it in GitHub Desktop.
public interface IFileIoReaderHelper
{
string ReadFromDefaultFile(string fileName);
}
public class FileIOReaderHelper : IFileIoReaderHelper
{
//Read the content from Json file
public string ReadFromDefaultFile(string fileName)
{
if (string.IsNullOrWhiteSpace(fileName))
{
throw new ArgumentNullException(nameof(fileName));
}
Uri appUri = new Uri(fileName);
IStorageFile anjFile = StorageFile.GetFileFromApplicationUriAsync(appUri).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();
string txtFile = FileIO.ReadTextAsync(anjFile).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();
return txtFile;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment