我正在尝试将图片 (.bmp) 插入 Filemaker 的容器字段中。我设法让它插入正常,但它将它保存为 .dat 文件。我想知道是否有办法指定将其保存为什么文件类型?
try
{
Bitmap tempImage = new Bitmap("C:\\temp\\black.bmp");
System.IO.MemoryStream stream = new System.IO.MemoryStream();
tempImage.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] image = stream.ToArray();
OdbcConnection connection = new OdbcConnection("DSN=Filemaker;UID=admin");
connection.Open();
OdbcCommand command = new OdbcCommand("INSERT INTO TestDatabase (LocatorNum, FileName, SampleSet, Image) VALUES (" +
"'003'" + ", " +
"'003'" + ", " +
"'003'" + ", " +
"?" + ")");
command.Connection = connection;
command.Parameters.AddWithValue("?", OdbcType.VarBinary).Value = image;
command.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}