建立一个类将下列代码添加进去
[DllImport("kernel32.dll")]
public static extern int GetCurrentThreadId();
[DllImport("kernel32.dll")]
public static extern int AllocConsole();
[DllImport("kernel32.dll")]
public static extern int FreeConsole();
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
/// <summary>
/// 获取短路径
/// </summary>
/// <param name="path">源路径</param>
/// <param name="shortPath">返回短路径</param>
/// <param name="shortPathLength">最大长度</param>
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName
(
[MarshalAs(UnmanagedType.LPTStr)]
string path,
[MarshalAs(UnmanagedType.LPTStr)]
StringBuilder shortPath,
int shortPathLength
);