Click here to Skip to main content
12,632,813 members (32,757 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# Windows .NET WPF system
Hi all,

For my Lan Messenger i like to display the user image. The image should be the Windows current Login user image.I got some link which say that the image of the current login user image will be available in this path C:\Users\<username>\AppData\Local\Temp\<username>.bmp. But i dont see that the LAN messanger will work only for Domain Login users. so where will the user image available. As of now i didn't get any links that gives the exact solution.

1. The user can login in any of windows operating system Xp,Vista, windows 7.
how can i get that user image.
Posted 26-Mar-12 0:40am
cpquest1.8K
Updated 26-Mar-12 0:54am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

For Vista and later, the image is located in C:\Users\UserName\AppData\Local\Temp\[UserName].bmp
  Permalink  
v2
Comments
Navin Kumar.K.Subramanian 26-Mar-12 6:06am
   
Hi,
ya i agree but the temp folder can be cleared manually or by using system cleanup. So the files in the temp folder will be deleted. and one more thing in that location we can't find the image often the image will be available only when the image is changed by the user for the first time and when you clear the temp folder it woun't get created again unless untill you change the existing image right so how can i get the image. Is there is any other option.
   
I've NEVER heard of anyone doing that. I think you're worrying about a non-issue.

If you want another way to do it, you're free to use google...
Navin Kumar K Subramanian 29-Mar-12 0:29am
   
Hey i have got the Answer for my Question thanks. if you want the code go to the below link

http://www.codeproject.com/Articles/42282/Get-a-User-s-Full-Name

and the code

private static void GetCurrentUserProfileImage()
{
var imageFile = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
@"\Microsoft\User Account Pictures\" + Environment.UserDomainName + "+" + Environment.UserName + ".dat");
if (!imageFile.Exists)
return;

var desktopSaveLocation = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) +
@"\" + Environment.UserDomainName + "+" + Environment.UserName + ".bmp");
byte[] originalImageBytes = new byte[imageFile.Length];
using (var imageInputStream = imageFile.OpenRead())
imageInputStream.Read(originalImageBytes, 0, (int)imageFile.Length);
using (var imageOutput = desktopSaveLocation.Create())
imageOutput.Write(originalImageBytes, 16, originalImageBytes.Length - 200);
}



and look in to my Comments jabit is very nice he reply me in a blink of eye. thanks a lot to him.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 26 Mar 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100