How to upload file using File control in ASP.NET - CsharpMagic.com

How to upload file using File control in ASP.NET

Introduction: In this article, I will show you How to upload file using File control in ASP.NET. It’s very common functionality whenever you as fresher/ 0-2 year of experience. I have seen many developers mostly stuck during developing file upload control. If you are an ASP.NET MVC developer you can check this How to upload file using File control in ASP.NET MVC.

Description: Nowadays almost every application required DataUpload and Data Extract option to play with data. So for the developer who is new in development field required to learn about How to upload a file using File control in ASP.NET/ASP.NET MVC.

Here I am demonstrating about this in details. First of all, create a page  in visual studio application like Default.aspx. Then add code as given below.

Namespace:  To work with the file in asp.net C#, we must need to work with System.IO namespace. which handles all kind of Input/output work.

Code Behind: Before Adding file to a folder, we need to check first that folder/directory exists or not. If not exists we need to create that it could not throw a directory exception.

 

Anand Kumar
@anandkumarv

Anand Kumar

Sr.Tech Lead at CsharpMagic
I am founder of csharpmagic.com and by profession Sr.Tech Lead. I like to explore New Technologies, New Business idea and many more
Anand Kumar
@anandkumarv

Anand Kumar

I am founder of csharpmagic.com and by profession Sr.Tech Lead. I like to explore New Technologies, New Business idea and many more

Leave a Reply

Your email address will not be published. Required fields are marked *