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

Did you trace through the code with the debugger ?
Is there actually a bitmap file with the user's name in that directory ?

// Jerry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.