Reputation: 15296
I am creating a class library. It contains several images. In WinRT app we can enumerate files from specific folder like this.
var folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");
var files = await folder.GetFilesAsync(); //which returns List<StorageFile>
While creating class library I can access single image like this
Assembly assembly = typeof(CLASS_NAME).GetTypeInfo().Assembly;
Stream manifestResourceStream = assembly.GetManifestResourceStream("MyImage.png")
The below line returns all the resources of whole assembly, not for particular folder.
string[] names = assembly.GetManifestResourceNames();
I tried this one, but didn't work. It throws exception The specified path (ms-appx:///LibraryName/Images) contains one or more invalid characters.
var sf = await StorageFolder.GetFolderFromPathAsync("ms-appx:///LibraryName/Images");
Now I have nearly 100+ image so in that way it will be donkey work, so how can I access the folder get the list of all the files ?
Please note I am creating class library for Windows Store App.
Upvotes: 2
Views: 2780
Reputation: 589
I just happen to solve this.
GetFolderFromPathAsync only accepts '\' (backslash), not '/' (slash).
When I use Application.dataPath
from Unity Project, it reports this error too.
Now I use
StorageFolder storageFolder = await
StorageFolder.GetFolderFromPathAsync(
Windows.ApplicationModel.Package.Current.InstalledLocation.Path +
@"\Data\Resources"
);
to get Unity's Resource folder.
Upvotes: 1