我尝试了这个......但不知道如何继续......我只想将文件放在图片框(picturebox1)中......并将其保存在sql server(2005)中并检索相同的......是否可以在图片框中加载文档...???如果不是,我应该使用什么控件来做同样的事情?
private void btnaddattach1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
if (btnaddattach1.Text == "ADD")
{
open.Filter = "Images Files(*.jpeg; *.gif; *.jpg; *.bmp; *.docx; *.pdf) | *.jpeg; *.gif; *.jpg; *.bmp; *.docx; *.pdf";
if (open.ShowDialog() == DialogResult.OK)
{
FileInfo finfo = new FileInfo(open.FileName);
if (finfo.Length < 2147483647)
{
byte[] imagearray = new byte[finfo.Length];
finfo.OpenRead().Read(imagearray, 0, (int)finfo.Length);
string imagedata = Convert.ToBase64String(imagearray);
}
else
{
MessageBox.Show("File too Large...", CPublic.messagename, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}