browsing to a file on button click in asp.net

Sree picture Sree · May 1, 2011 · Viewed 16.3k times · Source

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

Answer

Muhammad Akhtar picture Muhammad Akhtar · May 1, 2011

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!