I want to program a cute simple console app to set a random image from my image-folder as lock screen image. I just want to double click the program and, it searches the image folder, selects a random one and sets it as lock screen image without any user intervention.
My guess would be the following program:
Console.WriteLine("Set Random Lock Screen Image");
var myPicturesFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
var imageFileList = Directory.GetFiles(myPicturesFolder);
if (imageFileList.Length > 0)
{
var rnd = new Random();
var iNr = rnd.Next(imageFileList.Length);
var newImage = imageFileList[iNr];
Console.WriteLine($"set {newImage}");
var storageFile = StorageFile.GetFileFromPathAsync(newImage).GetResults();
LockScreen.SetImageFileAsync(storageFile).GetResults();
}
My only problem is, I can't find the assemblies containing StorageFile.GetFileFromPathAsync
and LockScreen.SetImageFileAsync
- what do I need to include to use these?
Or how else could I set the lock screen image? It does not need to be a console app, UWP would be fine, too, but I want to set the image without user interaction.