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

■ TargetFrameworkAttribute 클래스를 사용해 닷넷 프레임워크 파일 여부를 구하는 방법을 보여준다.

 

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

using System;

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

 

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

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
,