locked
Open Image on host folder RRS feed

  • Question

  • User-932576310 posted

    i try to show image on image folder locate on server 

    i only get file name, how to show image also ?

    here code i try please advice, thank you

    @using System.Web;
    @using System.IO;
    @{
        Page.Title = "open image";
        Layout = "~/adminpage/_SiteLayout.mobile.cshtml";
        
        DirectoryInfo path = new DirectoryInfo( HttpContext.Current.Server.MapPath("~/Images/Product"));
        System.Collections.Generic.List<string> urls = new System.Collections.Generic.List<string>();
        //string newimage = System.IO.File.Open(path);
          
    }
    
    <div>
        <ul>
            @foreach (FileInfo image in path.GetFiles())
            {            
                <li> @image, (show the image here )</li>            
            }
        </ul>
    </div>



    Wednesday, September 11, 2013 7:26 AM

Answers

  • User-821857111 posted

    You need to use an <img> tag to show an image:

    @foreach (FileInfo image in path.GetFiles()) { 
    <li> <img src="~/Images/Product/@image.Name" /></li>
    }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 11, 2013 7:29 AM

All replies

  • User-821857111 posted

    You need to use an <img> tag to show an image:

    @foreach (FileInfo image in path.GetFiles()) { 
    <li> <img src="~/Images/Product/@image.Name" /></li>
    }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 11, 2013 7:29 AM
  • User-932576310 posted

    ohh, i am not realised that,

    i thought i have to use streamreader or file.open ( )

    thank you mikes

    Wednesday, September 11, 2013 7:51 AM