Reputation: 24636
I've got a text file that ships with my app and I want to display its contents on the screen. Anyone know how to do that? The usual file IO doesn't seem to work for Metro.
Thanks
Upvotes: 0
Views: 1047
Reputation: 725
In my app I am reading a XML file that comes with the app, you can tweak it to read any type of file
public class LocalStorage
{
private const string SyndicationFeedCategoriesFileName = "FeedCategories.xml";
private StorageFile _storageFile;
private StorageFolder _storageFolder;
public async Task<XmlDocument> Read_categories_from_disk()
{
try
{
_storageFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Xml");
_storageFile = await _storageFolder.GetFileAsync(SyndicationFeedCategoriesFileName);
var loadSettings = new XmlLoadSettings
{ProhibitDtd = false, ResolveExternals = false};
return await XmlDocument.LoadFromFileAsync(_storageFile, loadSettings);
}
catch (Exception)
{
return null;
}
}
}
View the full source code here http://metrorssreader.codeplex.com/SourceControl/changeset/view/18233#263004
Hope that helps
Upvotes: 1
Reputation: 3162
Not sure what you've tried, but check this out:
With the StorageFolder in hand, you have the whole set of functions to read/write files.
Upvotes: 3