C # - How to get current user image

How can I get a registered user image in C #? Thanks

+1
source share
5 answers

This is not possible for every OS; but on the OS where possible:

For Windows Vista or later:

This image is located in C: \ Users \ username \ AppData \ Local \ Temp \ UserName.bmp

if the user is a domain user, he will "DOMAIN+UserName.bmp"(Yes, "+" is part of the file name)

+4
source

Try Ths ::

    public static Image GetUserimage()
    {  

        if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)+@"\Temp\"+Environment.UserName+".bmp"))
        {
            return Image.FromFile(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Temp\" + Environment.UserName + ".bmp");
        }
        else
        {
            return null;
        }
    }
+1
source

Windows 10

C:/users/username/appdata/romaing/microsoft/windows/account pictures/

+1

Joco AD, "usertile"

0

Microsoft Windows NuGet ( ):

https://github.com/HTD/Woof.System

, .

, , , Nuofet Woof.System, :

WPF:
var userBitmapSmall = new BitmapImage(new Uri(SysInfo.GetUserPicturePath()));
WPF:
var userBitmapSmall = new BitmapImage(new Uri(SysInfo.GetUserPicturePath("John")));
WPF:
var smallBitmapPath = SysInfo.GetUserPicturePath("John", out var largeBitmapPath);
var smallBitmap = new BitmapImage(new Uri(smallBitmapPath));
var largeBitmap = new BitmapImage(new Uri(largeBitmapPath));

, , Shell32.dll Windows Vista, , Windows 8 .

, Microsoft, - , , , Microsoft.

, , , :

  • Win32 API , , .
  • Win32 API Microsoft .

- , , GitHub.

Windows 10 ( ). Microsoft.

: , " ".

. .NET Framework .NET Core .NET Standard - Win32 API (, , -). Woof, .NET Standard. , XML, Visual Studio, GitHub , . Woof , .

0
source

All Articles