==> [FrmServerMapPath.aspx] 소스 및 디자인 

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmServerMapPath.aspx.cs" Inherits="FrmServerMapPath" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

   

        현재 파일(웹 폼)의 물리적인 전체 경로 :

        <asp:Label ID="Label1" runat="server"></asp:Label>

        <br />

        현재 스크립트 파일의 루트(웹서버상주소) 경로 :

        <asp:Label ID="Label2" runat="server"></asp:Label>

   

    </div>

    </form>

</body>

</html>

 




 

 

-------------------------------------------------------------------------------------

 


==> [FrmServerMapPath.aspx.cs] 소스
 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

public partial class FrmServerMapPath : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        // 현재 웹 폼의 서버측의 물리적 경로

        this.Label1.Text = Server.MapPath("."); // 같은 경로

 

        //현재 스크립트 파일의 루트 경로

        this.Label2.Text =

            Request.ServerVariables["SCRIPT_NAME"];

    }

}


 

-------------------------------------------------------------------------------------

 


[실행결과]









Posted by holland14
: