2021-07-27 16:53:28 +08:00
|
|
|
|
using IWshRuntimeLibrary;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace GeekDesk.Util
|
|
|
|
|
|
{
|
|
|
|
|
|
public class FileUtil
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetTargetPathByLnk(string filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
WshShell shell = new WshShell();
|
|
|
|
|
|
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtil.IsEmpty(shortcut.TargetPath))
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
return shortcut.TargetPath;
|
|
|
|
|
|
}
|
2021-12-10 17:58:23 +08:00
|
|
|
|
#pragma warning disable CS0168 // 声明了变量“e”,但从未使用过
|
2021-07-27 16:53:28 +08:00
|
|
|
|
catch (Exception e)
|
2021-12-10 17:58:23 +08:00
|
|
|
|
#pragma warning restore CS0168 // 声明了变量“e”,但从未使用过
|
2021-07-27 16:53:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|