byte[] big;
private System.Windows.Forms.OpenFileDialog OpenFD;
private void btnBrowse_Click(object sender, EventArgs e)
{
//this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
//openFileDialog1.ShowDialog();
//txtPhoto.Text = openFileDialog1.FileName;
//picImage.Image = "~/Images"+openFileDialog1.FileName;
this.OpenFD = new System.Windows.Forms.OpenFileDialog();
OpenFD.Title = "Select Files";
OpenFD.Filter = "Jpg|*.jpg|Jpge|*.jpge|Gif|*.gif";
OpenFD.FileName = null;
string fileName;
if (OpenFD.ShowDialog() != DialogResult.Cancel)
{
//querybuilder qu = new querybuilder();
fileName = OpenFD.FileName;
Object refmissing = System.Reflection.Missing.Value;
try
{
// show it to picturebox
picImage.Load(fileName);
// Here get_image is a function and Big is the byte[] type
big = get_image(fileName);
}
catch (Exception ex)
{
MessageBox.Show("Error" + ex.Message.ToString());
}
}
/* OpenFileDialog fileOpen = new OpenFileDialog();
fileOpen.Title = "Open Image file";
fileOpen.Filter = "JPG Files (*.jpg)| *.jpg";
if (fileOpen.ShowDialog() == DialogResult.OK)
{
picImage.Image = Image.FromFile(fileOpen.FileName);
}
fileOpen.Dispose();*/
}
private byte[] get_image(string filePath)
{
FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(stream);
byte[] photo = reader.ReadBytes((int)stream.Length);
reader.Close();
stream.Close();
return photo;
}