[英]cannot implicitly convert type void to int in C#
private string GetShortName(string LongName)
{
string ShortFileName = new string('\0', 67);
**int Result = Support.PInvoke.SafeNative.kernel32.GetShortPathName(ref LongName, ref ShortFileName, ((ShortFileName) is null) ? 0 : Convert.ToString(ShortFileName).Length);**
ShortFileName = StringsHelper.GetFixedLengthString(ShortFileName, 67);
return ShortFileName.Substring(0, Math.Min(Result, ShortFileName.Length));
}
The above line throws a error "cannot implicitly convert type void to int" GetShortPathName
comes from Kernel32.dll that is wrapped in a class file as上面的行抛出错误“无法隐式地将类型 void 转换为 int”
GetShortPathName
来自 Kernel32.dll,它被包装在 class 文件中
public static void GetShortPathName(ref string lpszLongPath, ref string lpszShortPath, int cchBuffer);
Is there is any alternative to get it in int
result?有没有其他方法可以在
int
结果中得到它?
GetShortPathName
should return a uint
, not be void
: GetShortPathName
应该返回一个uint
,而不是void
:
public static uint GetShortPathName(...)
If you don't have control over Support.PInvoke.SafeNative.kernel32
then you'll need to create a new wrapper around the kernel call that does return the uint
.如果您无法控制
Support.PInvoke.SafeNative.kernel32
,那么您需要围绕 kernel 调用创建一个新的包装器,该调用确实返回uint
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.