Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I am trying the following code I am getting this error

Could not find a part of the path plz send me answer.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            if (FileUpload1.PostedFile.ContentType =="image/bmp")
            {
                FileUpload1.PostedFile.SaveAs(Server.MapPath(".") + "\\uploadfiles\\" + FileUpload1.FileName);
                Label1.Text = "Upload Successfully....";
            }
            else
            {
                Label1.Text = "Upload BMP file....";
            }
        }
        else
            Label1.Text = "File Required...";
    }
  }
Posted
Comments
E.F. Nijboer 13-Dec-10 9:30am    
What's the error and where is it given.
rekha2010 13-Dec-10 9:34am    
FileUpload1.PostedFile.SaveAs(Server.MapPath(".") + "\\uploadfiles\\" + FileUpload1.FileName); on this line I am getting error i.e. Could not find a part of the path

1 solution

Server.MapPath(".") + "\\uploadfiles\\" +

Server.MapPath mean of directory inside your root folder of application.

Make sure that Uploadfiles is available under that directory.

Your hirarchy should be like this.

YourAppFolder/uploadfiles
 
Share this answer
 
Comments
rekha2010 13-Dec-10 10:10am    
Actually requirement is file uploading. Physically i am finding file is uploaded, but i am not not able to see application folder. could you please explain the reason.

Thanks in advance3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900