Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Server.Mappath

Server.Mappath

Scheduled Pinned Locked Moved ASP.NET
sysadminhelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kurian_Kurian
    wrote on last edited by
    #1

    Hi. in my web application there is a option for showing the photos,when click photos button will load photos.aspx page and am keeping the images in the server folder name Photos.in my local machine while loading the page i will get all the images which i store in the Photos folder,but i host this page and open this page am not getting any images.the page load event as follows.what is wrong with this code.somebody can help me. if (!IsPostBack) { DataSet ds = new DataSet(); DataTable dt = new DataTable("Photos"); dt.Columns.Add("Photos", Type.GetType("System.String")); foreach (string Files in Directory.GetFiles(Server.MapPath("Photos"), "*.jpg")) { dt.Rows.Add(Files); } ds.Tables.Add(dt); this.dgPhotos.DataSource = ds; this.dgPhotos.DataBind(); }

    D G 2 Replies Last reply
    0
    • K Kurian_Kurian

      Hi. in my web application there is a option for showing the photos,when click photos button will load photos.aspx page and am keeping the images in the server folder name Photos.in my local machine while loading the page i will get all the images which i store in the Photos folder,but i host this page and open this page am not getting any images.the page load event as follows.what is wrong with this code.somebody can help me. if (!IsPostBack) { DataSet ds = new DataSet(); DataTable dt = new DataTable("Photos"); dt.Columns.Add("Photos", Type.GetType("System.String")); foreach (string Files in Directory.GetFiles(Server.MapPath("Photos"), "*.jpg")) { dt.Rows.Add(Files); } ds.Tables.Add(dt); this.dgPhotos.DataSource = ds; this.dgPhotos.DataBind(); }

      D Offline
      D Offline
      DarrollWalsh
      wrote on last edited by
      #2

      Sounds like a permissions problem. Do you have view permissions to the root of the drive you are trying to view? Another option is to use classic asp style of debugging and output any errors, or even the path of the photos folder.

      Darroll

      1 Reply Last reply
      0
      • K Kurian_Kurian

        Hi. in my web application there is a option for showing the photos,when click photos button will load photos.aspx page and am keeping the images in the server folder name Photos.in my local machine while loading the page i will get all the images which i store in the Photos folder,but i host this page and open this page am not getting any images.the page load event as follows.what is wrong with this code.somebody can help me. if (!IsPostBack) { DataSet ds = new DataSet(); DataTable dt = new DataTable("Photos"); dt.Columns.Add("Photos", Type.GetType("System.String")); foreach (string Files in Directory.GetFiles(Server.MapPath("Photos"), "*.jpg")) { dt.Rows.Add(Files); } ds.Tables.Add(dt); this.dgPhotos.DataSource = ds; this.dgPhotos.DataBind(); }

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        The Directory.GetFiles returns an array of physical file paths on the server. As long as the server is the same computer as the client computer, you will be able to see the images, as you see the images that are stored locally on your computer, as they happen to have the exact same file path as the images that are stored on the server, as they happen to be the exact same files. When you view the page on the hosted server, the images are only stored on the server, so when you try to view the images they are not there, as you no longer have a local copy of the images on your computer with the same file paths as on the server. You have to make sure that you use the virtual path to each image, not the physical path, when you put them on the page.

        --- single minded; short sighted; long gone;

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups