Language/C#(CLR,.NET)

[C#] LINK(.LNK, 바로가기)파일의 실제 파일명 알아내기

천일몽 2013. 4. 1. 09:40

참조에 COM객체 “Windows Script Host Object Model”(1.0) 추가

 

   1: string fileName = @"Temp.lnk";
   2: string fileExt = Path.GetExtension(fileName);
   3: if (fileExt.Trim().ToLower() == ".lnk")
   4: {
   5:     IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
   6:     IWshRuntimeLibrary.IWshShortcut link = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(fileName);
   7:     fileName = link.TargetPath;
   8: }

출처 : 모름