go one level up of Application directory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parshupooja
    New Member
    • Jun 2007
    • 159

    go one level up of Application directory

    Hey All,

    I have following directory structure on server
    C:\data\inetpub \wwwroot\MyApp
    C:\data\inetpub \wwwroot\Images

    My App is my application and I have MyPage.aspx there. In that MyPage I want to access images from C:\data\inetpub \wwwroot\Images folder.

    I tried Server.Mappath( ) in several ways but it throws error.
    string filename = Server.MapPath( "~/Images/" + DateTime.Now.Ye ar.ToString() + "/Q" + currentquater.T ext.Trim());
    Any Idea?
    Thanks in advance
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Well, in this situation:
    C:\data\inetpub \wwwroot\MyApp
    C:\data\inetpub \wwwroot\Images

    Your could just use "/Images/imagename.jpg" without using any server.mappath or the ~ or anything?

    Comment

    • parshupooja
      New Member
      • Jun 2007
      • 159

      #3
      Ya i did that, it does not throw error but I can't see images either. Page loads without errors but intstead of images I see small cross sign
      string filename = "C:\data\inetpu b\wwwroot\Image s\" + DateTime.Now.Ye ar.ToString() + "/Q" + currentquater.T ext.Trim());

      thanks
      Originally posted by Plater
      Well, in this situation:
      C:\data\inetpub \wwwroot\MyApp
      C:\data\inetpub \wwwroot\Images

      Your could just use "/Images/imagename.jpg" without using any server.mappath or the ~ or anything?

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Try this:
        src= "\Images\" + DateTime.Now.Ye ar.ToString() + "/Q" + currentquater.T ext.Trim());

        You should be putting those direct file paths in like that for webpage.


        EDIT:
        Wait, I thought these were for <img> tags.
        You want to use them in the code behind?
        Which is it?

        Comment

        • parshupooja
          New Member
          • Jun 2007
          • 159

          #5
          nope this is not image tag. basically I am creating a file name in this string and than I m checking all images stored in filea and finally loading into datalist control.

          thanks
          Originally posted by Plater
          Try this:
          src= "\Images\" + DateTime.Now.Ye ar.ToString() + "/Q" + currentquater.T ext.Trim());

          You should be putting those direct file paths in like that for webpage.


          EDIT:
          Wait, I thought these were for <img> tags.
          You want to use them in the code behind?
          Which is it?

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Originally posted by parshupooja
            nope this is not image tag. basically I am creating a file name in this string and than I m checking all images stored in filea and finally loading into datalist control.

            thanks
            Well then, assuming your file-naming pattern is correct, this should work in backend:
            string filename = "C:\data\inetpu b\wwwroot\Image s\" + DateTime.Now.Ye ar.ToString() + "/Q" + currentquater.T ext.Trim());

            But you cannot use that format in image tags.

            Comment

            Working...