Save Files In Folders Other Than Root Folder Of Web Application

If your application uploads files to a Web server, the application folder is the default folder. To manage files better, you probably do not want to upload files in the application folder. Sometimes if there are large files or a number of files, you probably want to store them even on a different drives. 
Here is a quick tip on the same. We will create a simple Web application and upload files via this application.
Note: You need to make sure the folder you're using to upload files to has write permissions of the IIS or any application or user.  
Step 1: Create a folder named with test in D:\ drive or where you want to store the files.
Step 2: Create a Web application using Visual Studio and place a File Upload control to the default Web Form. Also place a Button control.
Step 3: On the button click event hander, write this code.  
  1. protected void Button1_Click(object sender, EventArgs e)  
  2. {  
  3. string filenam = FileUpload1.FileName.ToString();  
  4. string path = @"D:\test\";  
  5. path=path+filenam;  
  6. FileUpload1.PostedFile.SaveAs(path);  
  7. }  
Here is the .aspx file for these controls. 
  1. <asp:FileUpload ID="FileUpload1" runat="server" />     
  2. <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />  
  3. </div>  
Download the attached code for more details.
Note: If you still get access denied error, create a D:\Test folder or whatever full folder path you're using, go to the folder, right click and select Properties > Sharing > Share for everyone.
Here is a detailed tutorial on ASP.NET FileUpload Control and project sample how to upload files in ASP.NET.