How distinguish folders between files

CFile::GetStatus function can not distinguish
folders between files. I wanna
consider a file as a inexisting path (or folders) .
Because I want to send some files to the folder,
sending a file to file will turn to a ERROR.
How can I get the above purpose?
henry3Asked:
Who is Participating?
 
abdijConnect With a Mentor Commented:
This is what you you need to do.

After CFile::GetStatus(lpszFileName, rStatus) function call to get the status of the file

The second parameter to the function is the CFileStatus which contains a variable BYTE m_attribute :  The attribute byte of the file.

The m_attribute is the file attribute. The Microsoft Foundation classes provide an enum type attribute so that you can specify attributes symbolically:

enum Attribute {
   normal =    0x00,
   readOnly =  0x01,
   hidden =    0x02,
   system =    0x04,
   volume =    0x08,
   directory = 0x10,
   archive =   0x20
   };

check if the File is a directory by comparing
if(rStatus->m_attribute && 0x10)
{
  // this is a directory
}

Hope this is what you needed

Thanx.

Feel free to ask queries.
My mail id is abdij_b@hotmail.com
0
 
GlennDeanCommented:
Are you saying CFile::GetStatus can't distinguish between, for example,
  c:\windows\myFolder
and
  c:\windows\myFolder.exe
0
 
SampsonCCommented:
The correct code to abdij's solutions is-

if(rStatus->m_attribute & 0x10)
{
  // this is a directory
}

0
 
Ernest022699Commented:
SampsonC is correct.  (Remember, && is logical and; & is bitwise and.)

However, you should use the enumerated Attribute(symbolic name) "directory" instead of the magic number "0x10".
0
 
henry3Author Commented:
Thanks abdij, and everyone giving comments!
I got a perfect answer to my qestion.
But I think
  "rStatus->m_attribute & 0x10"
should be
  "rStatus.m_attribute & 0x10".
Is that right?
0
All Courses

From novice to tech pro — start learning today.