CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2009
    Posts
    4

    Question FindFileData.dwFileAttributes get wrong value! Any ideas?

    FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY

    FILE_ATTRIBUTE_DIRECTORY value is 16 or hex 0x00000010
    on my directory value is 17 or hex 0x00000011
    in MSDN i found all possible attributes but there is no my value... Any ideas???

    The file attributes. This member can be a combination of one or more of the following values.
    Attribute Meaning

    FILE_ATTRIBUTE_ARCHIVE
    32 (0x20)



    The file or directory is an archive file. Applications use this attribute to mark files for backup or removal.

    FILE_ATTRIBUTE_COMPRESSED
    2048 (0x800)



    The file or directory is compressed. For a file, this means that all of the data in the file is compressed. For a directory, this means that compression is the default for newly created files and subdirectories.

    FILE_ATTRIBUTE_DIRECTORY
    16 (0x10)



    The handle identifies a directory.

    FILE_ATTRIBUTE_ENCRYPTED
    16384 (0x4000)



    The file or directory is encrypted. For a file, this means that all data in the file is encrypted. For a directory, this means that encryption is the default for newly created files and subdirectories.

    FILE_ATTRIBUTE_HIDDEN
    2 (0x2)



    The file or directory is hidden. It is not included in an ordinary directory listing.

    FILE_ATTRIBUTE_NORMAL
    128 (0x80)



    The file does not have other attributes. This attribute is valid only if used alone.

    FILE_ATTRIBUTE_OFFLINE
    4096 (0x1000)



    The file data is not available immediately. This attribute indicates that the file data is physically moved to offline storage. This attribute is used by Remote Storage, the hierarchical storage management software. Applications should not arbitrarily change this attribute.

    FILE_ATTRIBUTE_READONLY
    1 (0x1)



    The file or directory is read-only. Applications can read the file, but cannot write to it or delete it. If it is a directory, applications cannot delete it.

    FILE_ATTRIBUTE_REPARSE_POINT
    1024 (0x400)



    The file or directory has an associated reparse point.

    FILE_ATTRIBUTE_SPARSE_FILE
    512 (0x200)



    The file is a sparse file.

    FILE_ATTRIBUTE_SYSTEM
    4 (0x4)



    The file or directory is part of the operating system or is used exclusively by the operating system.

    FILE_ATTRIBUTE_TEMPORARY
    256 (0x100)



    The file is being used for temporary storage. File systems avoid writing data back to mass storage if sufficient cache memory is available, because often the application deletes the temporary file after the handle is closed. In that case, the system can entirely avoid writing the data. Otherwise, the data will be written after the handle is closed.

    FILE_ATTRIBUTE_VIRTUAL
    65536 (0x10000)



    A file is a virtual file.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: FindFileData.dwFileAttributes get wrong value! Any ideas?

    The bits can be combined. 17 would be a read only directory.

  3. #3
    Join Date
    Apr 2009
    Posts
    4

    Re: FindFileData.dwFileAttributes get wrong value! Any ideas?

    FindFileData.dwFileAttributes == FILE_ATTRIBUTE_READONLY not equal. Can it be from different file system? or from diferent OS?

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: FindFileData.dwFileAttributes get wrong value! Any ideas?

    Quote Originally Posted by Rence View Post
    FindFileData.dwFileAttributes == FILE_ATTRIBUTE_READONLY not equal. Can it be from different file system? or from diferent OS?
    17 is not equal 1, so you don't check like that. You need to use bit masking.

    if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)

  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: FindFileData.dwFileAttributes get wrong value! Any ideas?

    Quote Originally Posted by Rence View Post
    FindFileData.dwFileAttributes == FILE_ATTRIBUTE_READONLY not equal. Can it be from different file system? or from diferent OS?
    So how would you represent a read-only directory? It is a combination of two of those values.

    16 - Directory
    1 - Read Only

    See how it works now? Those values are bits that are set within the return value. So if you want to check if the item is read only, and you don't care if it's a directory.
    Code:
    if ( FindFileData.dwFileAttributes & FILE_ATTRIBUTE_READONLY )
    If you don't know what the single "&" does, look up "bitwise AND" in your favourite C++ book.

    Regards,

    Paul McKenzie

  6. #6
    Join Date
    Apr 2009
    Posts
    4

    Re: FindFileData.dwFileAttributes get wrong value! Any ideas?

    thanks I got a point

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured