Upload and Save File To Other Drive on Place of WWWROOT or Application Directory in ASP.NET

Some times we need to store our file into a particular path on place of application directory. In that situation my this blog may be help full for you.

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 and take a file upload control and a button.

Step 3: Ob button click write this code

protected void Button1_Click(object sender, EventArgs e)

{

      string filenam = FileUpload1.FileName.ToString();

      string path = @"D:\test\";

      path=path+filenam;

      FileUpload1.PostedFile.SaveAs(path);

}

Aspx code

<asp:FileUpload ID="FileUpload1" runat="server" />

&nbsp;&nbsp;&nbsp;

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />    

</div>

For any issue..download the code.

NOTE - If u get access denied pb..then follow these steps

create a folder in d drive with test named and go to properies --sharing---and share for everyon

Ebook Download
View all
Learn
View all