public static Int32 TryGetFileAttributes([NotNull] String normalizedPath, out FileAttributes attributes) { var data = new WIN32_FILE_ATTRIBUTE_DATA(); var errorMode = NativeMethods.SetErrorMode(1); try { if (NativeMethods.GetFileAttributesEx(normalizedPath.ThrowIfBlank(), 0, ref data)) { attributes = data.fileAttributes; return(SUCCESS); } } finally { NativeMethods.SetErrorMode(errorMode); } attributes = ( FileAttributes )NativeMethods.INVALID_FILE_ATTRIBUTES; return(Marshal.GetLastWin32Error()); }
internal static extern bool GetFileAttributesEx(string name, int fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation);
public static extern Boolean GetFileAttributesEx([NotNull] String name, Int32 fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation);