첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ TargetFrameworkAttribute 클래스 : 닷넷 프레임워크 파일 여부 구하기 예제

using System;

Console.WriteLine(IsDotNetFrameworkFile(@"D:\TestProject\TestProject\bin\Debug\TestProject.exe"));

 

▶ TargetFrameworkAttribute 클래스 : 닷넷 프레임워크 파일 여부 구하기

using System.Linq;
using System.Reflection;
using System.Runtime.Versioning;

#region 닷넷 프레임워크 파일 여부 구하기 - IsDotNetFrameworkFile(filePath)

/// <summary>
/// 닷넷 프레임워크 파일 여부 구하기
/// </summary>
/// <param name="filePath">파일 경로</param>
/// <returns>닷넷 프레임워크 파일 여부</returns>
public bool IsDotNetFrameworkFile(string filePath)
{
    try
    {
        TargetFrameworkAttribute attribute = (TargetFrameworkAttribute)Assembly
            .LoadFrom(filePath)
            .GetCustomAttributes(typeof(TargetFrameworkAttribute)).First();

        return attribute != null;
    }
    catch
    {
        return false;
    }
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요