Here it also no longer works on Windows 11 now, probably due to a recent update of the Photos app. The same code still works on Windows 10, so apparently Microsoft has broken something in the Photos app. I thought that they may be blocking Desktop programs now, but then I tried the same code from a Windows Store app, and it also doesn't allow to switch between files in the Photos app.
Until recently it worked by setting the "NeighboringFilesQuery" option when launching the photos app. Example code for those who are interested:
Code: Select all
QueryOptions options = new QueryOptions();
options.ApplicationSearchFilter = "System.FileExtension:=(\".jpg\" OR \".png\")";
StorageFolder parent = await file.GetParentAsync(); // file is the StorageFile object to be launched
LauncherOptions launcherOptions = new LauncherOptions();
launcherOptions.NeighboringFilesQuery = parent.CreateFileQueryWithOptions(options);
ok = await Launcher.LaunchFileAsync(file, launcherOptions);
I have checked in the debugger, the query does return all the jpg and png files in the same directory. Launching the photos app this way on Windows 10 (and older Windows 11) allows to switch through all the images in the same folder. However, the new photos app on Windows 11 now seems to ignore this list.
Unfortunately I could not find out how the new photos app gets the list of files from Explorer.