Record Not Inserted SuccessfullyCould not find a part of the path 'D:\Hosting\7375777

Discussion in 'C#' started by mahimatha, Feb 23, 2012.

  1. #1
    Anyone know please rectify following error:

    Error:


    Record Not Inserted SuccessfullyCould not find a part of the path 'D:\Hosting\7375777\html\userside\clogo\indexrrr.jpg' is denied.



    coding:

    protected void btnupdate_Click(object sender, EventArgs e)
    {

    if (uploadlogo.HasFile == true)
    {
    try
    {
    //string fileName = Server.HtmlEncode(uploadcollogo.FileName);
    System.Drawing.Image image_file = System.Drawing.Image.FromStream(uploadlogo.PostedFile.InputStream);
    int image_height = image_file.Height;
    int image_width = image_file.Width;
    int max_height = 240;
    int max_width = 320;
    image_height = (image_height * max_width) / image_width;
    image_width = max_width;
    if (image_height > max_height)
    {
    image_width = (image_width * image_height) / image_width;
    image_width = max_width;
    }
    Bitmap bitmap_file = new Bitmap(image_file, image_width, image_height);
    System.IO.MemoryStream stream = new System.IO.MemoryStream();
    bitmap_file.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
    stream.Position = 0;
    byte[] image = new byte[stream.Length + 1];
    stream.Read(image, 0, image.Length);
    string fileName = Path.GetFileName(uploadlogo.FileName);
    //string savepath = "../userside/clogo/" + fileName;
    string status = "Active";
    //SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["constring"].ToString());
    SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
    cn.Open();
    SqlCommand cmd = new SqlCommand();
    cmd.CommandText = "pcompupdate";
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@cid", Convert.ToInt32(Session["comid"]));
    cmd.Parameters.AddWithValue("@cname", txtcompname.Text);
    cmd.Parameters.AddWithValue("@cmobile", txtcompmobile.Text);
    cmd.Parameters.AddWithValue("@clandline", txtcomplandline.Text);
    cmd.Parameters.AddWithValue("@cemail", txtcompemail.Text);
    cmd.Parameters.AddWithValue("@caltemail", txtalternateemail.Text);
    cmd.Parameters.AddWithValue("@cfaxno", txtcompfaxno.Text);
    cmd.Parameters.AddWithValue("@caddr", txtcaddr.Text);
    cmd.Parameters.AddWithValue("@ccategory", txtcategory.Text);
    cmd.Parameters.AddWithValue("@cwebsite", txtcompwebsite.Text);
    cmd.Parameters.AddWithValue("@ccity", txtcompcity.Text);
    cmd.Parameters.AddWithValue("@ccountry", ddlcountry.SelectedItem.Value);
    cmd.Parameters.AddWithValue("@cstate", ddlstate.SelectedItem.Text);
    cmd.Parameters.AddWithValue("@clandmark", txtcomplandmark.Text);
    cmd.Parameters.AddWithValue("@cstatus", status);
    SqlParameter UploadedImage = new SqlParameter("@clogo", SqlDbType.Image, image.Length);
    UploadedImage.Value = image;
    cmd.Parameters.Add(UploadedImage);
    cmd.Connection = cn;
    cmd.ExecuteNonQuery();
    uploadlogo.PostedFile.SaveAs(Server.MapPath("./userside/clogo/") + fileName);
    //uploadlogo.SaveAs(Server.MapPath("../userside/clogo/") + fileName);
    cn.Close();
    clear();
    Page.ClientScript.RegisterStartupScript(this.GetType(), "Updated", "<script>alert('Record Updated Sucessfuly')</script>");

    }

    catch (Exception ex)
    {
    lblerrmsg.Text = "Record Not UPdated" + ex.Message;

    }

    }

    }
     
    mahimatha, Feb 23, 2012 IP
  2. geekstrack

    geekstrack Well-Known Member

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    121
    #2
    the problem in your hosting your directory does not have writing permissions..
     
    geekstrack, Feb 23, 2012 IP