アプリに同梱されているテキスト ファイルがあり、その内容を画面に表示したいと考えています。誰もそれを行う方法を知っていますか? 通常のファイル IO は Metro では機能しないようです。
ありがとう
アプリに同梱されているテキスト ファイルがあり、その内容を画面に表示したいと考えています。誰もそれを行う方法を知っていますか? 通常のファイル IO は Metro では機能しないようです。
ありがとう
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.
私のアプリでは、アプリに付属の XML ファイルを読み取っています。任意の種類のファイルを読み取るように微調整できます。
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;
}
}
}
ここで完全なソース コードを表示します。
それが役立つことを願っています