简体   繁体   中英

is there any Possibility that i could Load a document or pdf file in picturebox control in Visual studio ???if so how?

I tried Upto this ... but not sure how to proceed... i just want the file to be in the picturebox(picturebox1)...and to save it in sql server(2005) and also retrieve the same ...is it possible to load documents in picturebox...??? if not what control should i use to do the same??

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);
                        }
                    }

That doesn't work. You cannot just read the document as bunch of bytes and display that. You need a special control to display the corresponding document type, such as the acrobat reader Ocx control for pdf. You can save stuff to the database this way, though.

To answer in short you can't. As per the Documentation the supported formats are BMP, GIF, EXIG, JPG, PNG and TIFF.

Note: There seem to be a number of converters to be found through Google, that might help you out. You can try this

You can create your database table with 2 columns first for File storage and second for its type (for file name or type) FileStore column datatype must be VARBINARY(MAX) and For file type will be varchar

for save and retrive file from databse you can check this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM