从资产Windows应用商店应用程序获取所有文件

时间:2014-01-25 10:12:35

标签: c# windows-store-apps

我正在开发Windows应用商店应用,并在Assets / Backgrounds文件夹中有大约20个图像。

如何从C#获取这些文件?

我只需要文件路径,例如我需要创建一个带有文件路径的strings对象列表。例如,列表可以采用

的格式
List<string> files = new List<string> {"Assets/Backgrounds/file1.jpg", 
     "Assets/Backgrounds/file2.jpg", ...};

由于

2 个答案:

答案 0 :(得分:2)

首先,您需要了解内容的路径

string ImagesFile = @"Assets/Backgrounds/file1.jpg";

然后你可以访问像这样的文件:

StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
        StorageFile file = await InstallationFolder.GetFileAsync(ImagesFile);

答案 1 :(得分:1)

这包含应用程序包中的所有文件

   ResourceManager.Current.MainResourceMap

使用Linq过滤您需要的那些