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
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] MailMessage 클래스 : EML 파일 저장하기 (0) | 2021.08.06 |
---|---|
[C#/COMMON] 실수 확장(double extension) 기능 사용하기 (0) | 2021.07.17 |
[C#/COMMON] AssemblyName 클래스 : ProcessorArchitecture 속성을 사용해 플랫폼 프로세서 구하기 (0) | 2021.07.06 |
[C#/COMMON] Assembly 클래스 : GetModules 메소드를 사용해 모듈 정보 구하기 (0) | 2021.07.06 |
[C#/COMMON] Assembly 클래스 : ManifestModule 속성을 사용해 메니페스트 모듈의 플랫폼 대상 구하기 (0) | 2021.07.06 |
[C#/COMMON] PE(Portabl Executable) 파일 버전 구하기 (0) | 2021.07.06 |
[C#/COMMON/.NET5] CancellationTokenSource 클래스 : 지정 시간 이후 취소하는 토큰 소스 생성하기 (0) | 2021.06.26 |
[C#/COMMON/.NET5] HttpClient 클래스 : 다운로드 중 에러 발생으로 재시도시 지연 시간 늘리기 (0) | 2021.06.26 |
[C#/COMMON] 누겟 설치 : System.Collections.Immutable (0) | 2021.06.26 |
[C#/COMMON] 누겟 설치 : System.Threading.Channels (0) | 2021.06.26 |