직접 확인해 볼까요 ??



코드를 보겠습니다.



TEST5.aspx


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test5.aspx.cs" Inherits="FrmText.test5" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        현재 프로젝트의 물리적인 경로 가져오기 <br / />
        <asp:Label ID="Lable1" runat="server" /><br />
        현재 파일 경로 가져오기 <br />
        <asp:Label ID="Lable2" runat="server" />
    </div>
    </form>
</body>
</html>
 
cs



test5.aspx.cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace FrmText
{
    public partial class test5 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // 물리적 경로 가져오기
            this.Lable1.Text = Server.MapPath(".");
            // 현재 파일 루트 경로
            this.Lable2.Text = Request.ServerVariables["SCRIPT_NAME"];
        }
    }
}
cs


+ Recent posts