c# - Search files in project folder dynamically -


in windows store project have .jpg files in assets folder. how can dynamically .jpg files folder?

i've tried:

storagefolder folder = await storagefolder.getfolderfrompathasync("ms-appx:///assets/"); var filelist = await folder.getfilesasync(commonfilequery.defaultquery); 

must work somehow (with different commonfilequery) not working me. (system exception @ line 1 - wrong path name).

second question: how test if assets folder contains "movie.mp4"?

thank you!

you can use directory.enumeratefiles(sourcedirectory, "*.jpg", searchoption.alldirectories);

question 2:

you can use file.exists(filepath);

edit per comment, found this uses getfilefromapplicationuriasync instead of getfolderfrompathasync

or

storagefolder installedlocation = windows.applicationmodel.package.current.installedlocation; var files = installedlocation.getfolderfrompathasync("assets"); 

q2 seems can use

trygetitemasync


Comments