1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development asp.NET novice help

Discussion in 'Software' started by Fusen, 13 Jan 2006.

  1. Fusen

    Fusen New Member

    Joined:
    17 Jan 2004
    Posts:
    351
    Likes Received:
    0
    I'm a complete novice at asp/asp.NET and am trying to edit a script so that it'll link to itself but using Request.Servervariables("URL"); so the link is created dynamicly depending on what the filename is

    Code:
    <% @Page Language="C#" %>
    <% @Import Namespace="System.IO" %>
    <%
    string strDir2List = Request.QueryString.Get("dir");
    string currentpage = Request.Servervariables("URL");
    DirectoryInfo thisOne = null;
    try
    {
     thisOne = new DirectoryInfo(strDir2List);
     // Reading the directory properties
     Response.Write("<p>Creation: " + 
     thisOne.CreationTime.ToString() + "</p>");
     DirectoryInfo[] subDirectories = thisOne.GetDirectories();
     Response.Write("<ul>");
     for (int i=0; i < subDirectories.Length; i++)
     {
      Response.Write("<li><a href=\""& currentpage &"?dir=");
      Response.Write(Server.UrlEncode(subDirectories[i].FullName));
      Response.Write("\">" + subDirectories[i].Name);
      Response.Write("</a><br>");
     }
     Response.Write("</ul>");
     
     FileInfo[] theFiles = thisOne.GetFiles();
     Response.Write("<ul>");
     for (int i=0; i < theFiles.Length; i++)
     {
      Response.Write("<li><a href=\"fusen186328filecontents.jpg.aspx?file=");
      Response.Write(Server.UrlEncode(theFiles[i].FullName));
      Response.Write("\">" + theFiles[i].Name);
      Response.Write("</a><br>");
     }
     Response.Write("</ul>");
    }
    catch (Exception e)
    {
     Response.Write("Access not possible, error: <i>");
     Response.Write(e.ToString() + "</i>");
     Response.End();
    }
    %>
    I made the two ammendments

    string currentpage = Request.Servervariables("URL");
    and
    Response.Write("<li><a href=\""& currentpage &"?dir=");

    but it just gives me an error, any help would be much appreciated +k
     

Share This Page