728x90
반응형
728x170
■ PathCanonicalize API 함수를 사용해 표준 경로를 구하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System.Runtime.InteropServices;
using System.Text;
#region 표준 경로 구하기 - PathCanonicalize(targetPathStringBuilder, sourcePath)
/// <summary>
/// 표준 경로 구하기
/// </summary>
/// <param name="targetPathStringBuilder">타겟 경로 StringBuilder</param>
/// <param name="sourcePath">소스 경로</param>
/// <returns>처리 결과</returns>
[DllImport("shlwapi.dll", CharSet = CharSet.Auto)]
public static extern int PathCanonicalize([Out] StringBuilder targetPathStringBuilder, string sourcePath);
#endregion
...
string sourcePath = @"c:\windows\system32\drivers\..\notepad.exe";
StringBuilder targetPathStringBuilder = new StringBuilder();
PathCanonicalize(targetPathStringBuilder, sourcePath);
Console.WriteLine(targetPathStringBuilder.ToString());
※ 'c:\windows\system32\drivers\..\notepad.exe' → 'c:\windows\system32\notepad.exe' 값이 변환될 것으로 예상했으나 'c:\windows\system32\notepad.'를 반환했다.
728x90
반응형
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] 파일 히든 속성 보유 여부 조사하기 (0) | 2016.06.01 |
---|---|
[C#/COMMON] 파일 읽기 전용 속성 보유 여부 조사하기 (0) | 2016.06.01 |
[C#/COMMON] 디렉토리 크기 구하기 (0) | 2016.06.01 |
[C#/COMMON] 바이너리 파일 관리자 (0) | 2016.06.01 |
[C#/COMMON] 논리적 드라이브 타입 구하기 (0) | 2016.06.01 |
[C#/COMMON] Directory 클래스 : GetLogicalDrives 정적 메소드를 사용해 논리적 드라이브명 배열 구하기 (0) | 2016.06.01 |
[C#/COMMON] Directory 클래스 : 자식 디렉토리 경로 배열 구하기 (0) | 2016.06.01 |
[C#/COMMON] Directory 클래스 : 파일 경로 배열 구하기 (0) | 2016.06.01 |
[C#/COMMON] DirectoryInfo 클래스 : 디렉토리명 구하기 (0) | 2016.06.01 |
[C#/COMMON] FileInfo 클래스 : 파일명 구하기 (0) | 2016.06.01 |
댓글을 달아 주세요