0

アプリに同梱されているテキスト ファイルがあり、その内容を画面に表示したいと考えています。誰もそれを行う方法を知っていますか? 通常のファイル IO は Metro では機能しないようです。

ありがとう

4

2 に答える 2

3

Not sure what you've tried, but check this out:

http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.package.installedlocation.aspx

With the StorageFolder in hand, you have the whole set of functions to read/write files.

于 2012-07-29T01:42:37.027 に答える
1

私のアプリでは、アプリに付属の 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;
        }
    }
}

ここで完全なソース コードを表示します

それが役立つことを願っています

于 2012-07-29T05:35:31.387 に答える