示例#1
0
        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());
        }
示例#2
0
 internal static extern bool GetFileAttributesEx(string name, int fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation);
示例#3
0
 public static extern Boolean GetFileAttributesEx([NotNull] String name, Int32 fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation);