/// <summary> /// Gets the profile image for the current user. /// </summary> /// <returns></returns> public static Bitmap GetProfileImage() { string profileImagePath = @Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Microsoft\Windows\AccountPictures\"); string profileImage = Directory.GetFiles(profileImagePath).FirstOrDefault(); return(AccountPictureConverter.GetImage448(profileImage)); }
public static Uri GetProfileImagePath() { string profileImagePath = @Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Microsoft\Windows\AccountPictures\"); string profileImage = Directory.GetFiles(profileImagePath).FirstOrDefault(); // Convert to bitmap and save before setting src try { var final = AccountPictureConverter.GetImage448(profileImage); final.Save("profile-img.png"); if (File.Exists(".\\profile-img.png")) { return(new Uri(@".\profile-img.png", UriKind.Relative)); } } catch (Exception e) { Console.WriteLine(e.Message); } // Unable to find image, use default icon. return(new Uri(".\\Resources\\usericon.png")); }