how do i set a default image when the image file was not found or not exist ? the error i got was
because file with name 8813.jgp
was not exist. and i want to set it default as 1.jpg
. how do i check if its exist or not.
iam using this code
public void profilepicture()
{
DataTable dtprofile = new DataTable();
DataSet dsprofile = new DataSet();
string path;
SqlCommand command = new SqlCommand();
SqlDataAdapter adapter = new SqlDataAdapter();
try
{
dsprofile.Clear();
dtprofile.Clear();
command.Connection = myConnection;
command.CommandText = "//some query//'";
myConnection.Open();
adapter.SelectCommand = command;
adapter.Fill(dtprofile);
adapter.Fill(dsprofile);
}
catch (Exception ex)
{
MessageBox.Show("error" + ex);
myConnection.Close();
}
path = dsprofile.Tables[0].Rows[0][0].ToString() + "\\" + number + ".jpg";
pictureEdit2.Image = Image.FromFile(path);
myConnection.Close();
}