1、声明static extern 方法,使用DllImport特性
class MyClass { [DllImport("kernel32", SetLastError = true)] public static extern int GetCurrentDirectory(int a, StringBuilder b); }
2、调用
StringBuilder sb=new StringBuilder {Length = 250};
MyClass.GetCurrentDirectory(250, sb);
Console.WriteLine(sb);
Console.Read();