Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Upload in C# windows Application

Tags:

c#

winforms

In my C# Windows application I want to upload a pdf file but in my toolbox I cannot find a FileUpload control.

How can I go about and uploading a pdf file in a C# windows application.?

regards

like image 798
Arianule Avatar asked Nov 14 '12 11:11

Arianule


2 Answers

After you put a OpenFileDialog control on your form, let's say that you click a button and:

    private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();
            if (result == DialogResult.OK) // Test result.
            {
            //Do whatever you want
            //openFileDialog1.FileName .....
            }
        }

it goes something like this :-)

like image 54
Sylca Avatar answered Sep 23 '22 16:09

Sylca


You can use OpenFileDialog to get the filename of the file you need and then .NET File object to read data from the file. You might need a control being able to display a PDF file. Please read the following:

Viewing PDF in Windows forms using C#

like image 21
Legoless Avatar answered Sep 23 '22 16:09

Legoless