blogspot visit counter

Wednesday, 14 August 2013

Could not find file exception in asp.net fileupload

Categories : - Create and read XML file in asp.net  , Interview question and answer , Regular expression image validation , Regular expression text box validate for numeric value onlyCould not find file exception in asp.net fileupload

Introduction :-

In this article i am explain how to avoid error file cloud not find when upload any image in folder using asp.net web form .

Error As shown below



Description : - 

 In my Previous article i have explained how to upload  only image in .png,.jpeg format.  Now I am explain how to solve the server error could not find file when file is uploaded in image folder using file upload control of  asp.net.

Solution :- 

Use Server.MapPath for upload file in folder. Process for upload file on server side as shown below.

Create a  new  website and add new web Form .give the name to the web Form fileupload.aspx  .And drag and drop a new asp.net file upload control and asp.net button control. and double click on  button that means on code behind side write this code on button click event.




  protected void Button1_Click(object sender, EventArgs e)
    {
        string image1 = File1.FileName.ToString();
        string imgPath1 = "~/image/"+ image1;
        File1.SaveAs(Server.MapPath(imgPath1));
    }


 Here "~/image/" virtual path of the image  folder.



Download sample code attached




1 comment:

Related Posts Plugin for WordPress, Blogger...