This simplified test works for me (Windows 10 21H1), as x64,
with a PictureBox to display the new image =>
At beginning :
// Add reference to : "C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd"
// For .AsStream()
// Add reference to : "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll"
// For .AsStream()
using System.IO;
using System.Runtime.InteropServices.WindowsRuntime;
Test code :
string sFilename = @"E:\Tools\Graphism\Images\Paradise.jpg";
Windows.Storage.StorageFile imageFile = await Windows.Storage.StorageFile.GetFileFromPathAsync(sFilename);
await Windows.System.UserProfile.LockScreen.SetImageFileAsync(imageFile);
Uri sImage = Windows.System.UserProfile.LockScreen.OriginalImageFile;
Windows.Storage.Streams.IRandomAccessStream stream = Windows.System.UserProfile.LockScreen.GetImageStream();
using (StreamReader sr = new StreamReader(stream.AsStream()))
{
this.pictureBox1.Image = System.Drawing.Image.FromStream(sr.BaseStream);
}
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
I have tried your code and I got this in the picture box this is not that image I have set also the image has not changed on the lock screen.
Did you test as x64 ?
Yes, I tried.
Here's the code, can you please test this, perhaps I could have some library version issue.
Thanks
https://we.tl/t-Yn37OetrJb
There is no x64 configuration in this project.
If I add it, it works...
I have changed the configuration to x64 from project properties and used this method LockScreen.SetImageStreamAsync() and the issue is resolved!!!
Thanks for your help.
Really appreciate.
Sign in to comment