// Extract out the name of the file an use it for the name
// of the photo
// string strName = System.IO.Path.GetFileNameWithoutExtension(file);
// Insert the image into the database and add it to the tree
if (frm_infoList.numberfee ==null)
{
if(file==null)
{
MessageBox.Show ("相片不能为空!","提示",MessageBoxButtons.OK ,MessageBoxIcon.Information );
return;
}
System.IO.FileStream stream = new System.IO.FileStream(file,
System.IO.FileMode.Open,
System.IO.FileAccess.Read);
// Create a buffer to hold the stream bytes
buffer = new byte[stream.Length];
// Read the bytes from this stream
stream.Read(buffer, 0, (int)stream.Length);
// Now we can close the stream
stream.Close();
cm.Parameters ["@photo"].Value =buffer;
}
else
{
if(modPhoto)
{
if(file==null)
{
MessageBox.Show ("相片不能为空!","提示",MessageBoxButtons.OK ,MessageBoxIcon.Information );
return;
}
System.IO.FileStream stream = new System.IO.FileStream(file,
System.IO.FileMode.Open,
System.IO.FileAccess.Read);
// Create a buffer to hold the stream bytes
buffer = new byte[stream.Length];
// Read the bytes from this stream
stream.Read(buffer, 0, (int)stream.Length);
// Now we can close the stream
stream.Close();
cm.Parameters ["@photo"].Value =buffer;
}
else