Пример #1
0
        /// <remarks>
        ///     Will return WindowsNative.INVALID_FILE_ATTRIBUTES if failed and throwException is false.
        /// </remarks>
        /// <exception cref='Win32Exception'>
        ///     Call to native windows function failed.
        /// </exception>
        public FileAttributes GetFileAttributes(bool throwException)
        {
            FileAttributes retval = WindowsNative.INVALID_FILE_ATTRIBUTES;

            if (!KtmTransaction.IsInTransaction)
            {
                retval = WindowsNative.GetFileAttributes(PathString);
            }
            else
            {
                WindowsNative.WIN32_FILE_ATTRIBUTE_DATA attrData = new WindowsNative.WIN32_FILE_ATTRIBUTE_DATA();
                if (WindowsNative.GetFileAttributesTransacted(
                        PathString
                        , WindowsNative.GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard
                        , out attrData
                        , KtmTransaction.Current.Hanlde))
                {
                    retval = attrData.dwFileAttributes;
                }
            }

            Check.DoAssertLambda(!throwException || retval != WindowsNative.INVALID_FILE_ATTRIBUTES, () => new Win32Exception());

            return(retval);
        }