hi all,
i want to write a c# code that display the picture of user's windows account in picturebox, so if any one know how do you call and display the user's picture in a picturebox using c#
I try the following code but nothing happened:
private void button1_Click(object sender, EventArgs e)
{
Image myimage = GetUserImage();
pictureBox1.Image = myimage;
}
private Image GetUserImage()
{
string TempPath = Environment.GetEnvironmentVariable("TEMP");
MessageBox.Show(TempPath);
string UserName = Environment.GetEnvironmentVariable("USERNAME");
MessageBox.Show(UserName);
string ImagePath = String.Format("{0}\\{1}.bmp", TempPath, UserName);
if (System.IO.File.Exists(ImagePath))
{
MessageBox.Show("there is an image");
return Image.FromFile(String.Format("{0}\\{1}.bmp", TempPath, UserName));
}
else
{
MessageBox.Show("null");
return null;
}
}
if any one has any idea, please tell me soon.
thank you very much