本文整理汇总了C#中Microsoft.Win32.Win32Native.PopulateFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Win32Native.PopulateFrom方法的具体用法?C# Win32Native.PopulateFrom怎么用?C# Win32Native.PopulateFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Win32.Win32Native
的用法示例。
在下文中一共展示了Win32Native.PopulateFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillAttributeInfo
internal static int FillAttributeInfo(string path, ref Win32Native.WIN32_FILE_ATTRIBUTE_DATA data, bool tryagain, bool returnErrorOnNotFound)
{
int num = 0;
if (tryagain)
{
Win32Native.WIN32_FIND_DATA win_find_data = new Win32Native.WIN32_FIND_DATA();
string fileName = path.TrimEnd(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });
int num2 = Win32Native.SetErrorMode(1);
try
{
bool flag = false;
SafeFindHandle handle = Win32Native.FindFirstFile(fileName, win_find_data);
try
{
if (handle.IsInvalid)
{
flag = true;
num = Marshal.GetLastWin32Error();
if ((((num == 2) || (num == 3)) || (num == 0x15)) && !returnErrorOnNotFound)
{
num = 0;
data.fileAttributes = -1;
}
return num;
}
}
finally
{
try
{
handle.Close();
}
catch
{
if (!flag)
{
__Error.WinIOError();
}
}
}
}
finally
{
Win32Native.SetErrorMode(num2);
}
data.PopulateFrom(win_find_data);
return num;
}
bool flag2 = false;
int newMode = Win32Native.SetErrorMode(1);
try
{
flag2 = Win32Native.GetFileAttributesEx(path, 0, ref data);
}
finally
{
Win32Native.SetErrorMode(newMode);
}
if (!flag2)
{
num = Marshal.GetLastWin32Error();
if (((num != 2) && (num != 3)) && (num != 0x15))
{
return FillAttributeInfo(path, ref data, true, returnErrorOnNotFound);
}
if (!returnErrorOnNotFound)
{
num = 0;
data.fileAttributes = -1;
}
}
return num;
}