How to upload file in ASP.NET

You could upload a file on the hosting server using the following C# code:

String sPath = Server.MapPath(“UploadFolder”);

String sFileName = “YourFileName.txt”

File.SaveAs(sPath + sFilename);

Right-click on the folder (UploadFolder folder), and then select Properties. In the Properties dialog box, click on the Security tab and make sure the ASP.NET Machine Account is included in the list and has the proper permissions to write to disk