Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7927373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:16:45+00:00 2026-06-03T19:16:45+00:00

I was trying to add an image into a directory by using c#. I’m

  • 0

I was trying to add an image into a directory by using c#. I’m going to use this image to display in a gridview. I wrote the code but I’m getting an error and I couldn’t solve it. I have a directoy called images. This is where I’m getting error FileUpload1.SaveAs (Server.MapPath(“images/” + FileName). It says C:\Users\user\Documents\Visual Studio 2008\WebSites\WebSite1\images\im1.jpg’ part of path couldn’t be found. Here is my code:

string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(Server.MapPath("images/" + FileName));
String strConnString = System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
string strQuery = "INSERT INTO Books (Book_Name,Author_Name,FileName, FilePath, In_Lib) VALUES (@BN,@AN,@FileName, @FilePath,@LIB)";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.Parameters.AddWithValue("@BN", TextBox1.Text);
cmd.Parameters.AddWithValue("@AN", TextBox2.Text);
cmd.Parameters.AddWithValue("@FileName", FileName);
cmd.Parameters.AddWithValue("@FilePath", "images/" + FileName);
cmd.Parameters.AddWithValue("@LIB", "YES");
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:16:46+00:00Added an answer on June 3, 2026 at 7:16 pm

    You are trying to save into a non existing directory.

    You need to create the directory hierarchy before you can save to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add a second image into my custom dialog but I
I am trying to add an image into a document using WordML. I have
I am trying to add n image to a panel using Netbeans. I dragged
I 'm trying to add text on a specific image. Its working perfectly but
i'm trying to add some animated gif into static image (canvas), here's my start
I'm trying to add two image files into the solution, so they will be
I am trying to add a simple figure into my latex code .I have
I have a javascript map I'm using and I'm trying to add an image
I'm trying to add a row into a mysql database table using visual studio
i am trying to load a .TIF formatted image to add into Jlist and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.