Sreedhar Danturthi
Sreedhar Danturthi

Reputation: 7601

browsing to a file on button click in asp.net

I want to browse to folder on button click and select a file in that folder. When user selects a particular file. I want to retrieve the folder path and size of that file ?

How can i do that in asp.net with c#

BTW i'm using vs2008.

Please help me

Thanks in anticipation

Upvotes: 2

Views: 17638

Answers (2)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

Why not use the FileUpload control instead of a Button? http://asp.net-tutorials.com/controls/file-upload-control/

Using FileUpload control, it will accept file uploads from users and is extremely easy. With the FileUpload control, it can be done with a small amount of lines of code, as you will see in the following example. However, please notice that there are security concerns to to consider when accepting files from users!

Upvotes: 2

Kon
Kon

Reputation: 27451

Use the FileUpload control to let user browse to the file, select it and upload it. Unfortunately, there is no way to retrieve the file size until the file is uploaded (without using Silverlight or other third-party browser components). Once the file is uploaded, you can retrieve file size via the ContentLength property.

Upvotes: 2

Related Questions