본문 바로가기
C# /WindowsForm

C# 현재 실행중인 자기 자신의 파일명 정보 얻기 예제

by Hwoarang757 2016. 3. 7.

 

Reflection 클래스를 이용하여 얻는 방법을 찾았습니다.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//
using System.Reflection;
using System.IO;

namespace ConsoleUnitTest
{
    class Program
    {
        static void Main(string[] args)
        {
            //전체 경로
            Console.WriteLine(Assembly.GetEntryAssembly().Location);
            // 파일명 만 얻어오기
            Console.WriteLine(Path.GetFileName(Assembly.GetEntryAssembly().Location));
        }
    }
}