From: LondonLad on
I am using Randy Birch's CopyFileEx: Create a File Backup App

Option Explicit
Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10

I am stuck as I cannot see why this line of code does not work:-

1. When they are equal
2. When they are not equal

I am getting the same result nothing within the if statement is being called
whether they are equal or not.

'if the object is not a folder..
If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <>
FILE_ATTRIBUTE_DIRECTORY Then

other code

end if

When the WFDSource.dwFileAttributes is not a folder its value = 17 and when
it is a folder its value = 16

FILE_ATTRIBUTE_DIRECTORY value = 16 is it the
And FILE_ATTRIBUTE_DIRECTORY that is causing the problem?

Can you help?



From: Kevin Provance on

"LondonLad" <LondonLad(a)discussions.microsoft.com> wrote in message
news:7D3A36E3-8722-494B-91D2-6E1A725EEB5D(a)microsoft.com...
:I am using Randy Birch's CopyFileEx: Create a File Backup App
:
: Option Explicit
: Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10
:
: I am stuck as I cannot see why this line of code does not work:-
:
: 1. When they are equal
: 2. When they are not equal
:
: I am getting the same result nothing within the if statement is being
called
: whether they are equal or not.
:
: 'if the object is not a folder..
: If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <>
: FILE_ATTRIBUTE_DIRECTORY Then
:
: other code
:
: end if
:
: When the WFDSource.dwFileAttributes is not a folder its value = 17 and
when
: it is a folder its value = 16
:
: FILE_ATTRIBUTE_DIRECTORY value = 16 is it the
: And FILE_ATTRIBUTE_DIRECTORY that is causing the problem?
:
: Can you help?

Okay, I'll be the one to ask. Do you understand the concept bit operations?
If not, the answer won't make any sense to you. Google "Logical and Bitwise
operators". The answer should then be apparent.

From: MikeD on


"LondonLad" <LondonLad(a)discussions.microsoft.com> wrote in message
news:7D3A36E3-8722-494B-91D2-6E1A725EEB5D(a)microsoft.com...
> I am using Randy Birch's CopyFileEx: Create a File Backup App
>
> Option Explicit
> Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10
>
> I am stuck as I cannot see why this line of code does not work:-
>
> 1. When they are equal
> 2. When they are not equal
>
> I am getting the same result nothing within the if statement is being
> called
> whether they are equal or not.
>
> 'if the object is not a folder..
> If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <>
> FILE_ATTRIBUTE_DIRECTORY Then
>
> other code
>
> end if

That code is fine.

>
> When the WFDSource.dwFileAttributes is not a folder its value = 17 and
> when
> it is a folder its value = 16

Here's where you're mistaken. If dwFileAttributes has a value of 17, then it
IS a directory that also has the read-only attribute. The constant for this
attribute is:

Public Const FILE_ATTRIBUTE_READONLY = &H1

In decimal form, the values are 16 (for directory) and 1 (for read-only).
Added together, it means that BOTH attributes are present. Try this in the
Immediate window:

? 17 and 16

This will print 16 into the immediate window. For a little bit closer
representation of your code above, try this in the immediate window:

? (17 and 16) <> 16

Note that it prints False.

The problem doesn't appear to be with the code. Verify what you have for
the cFileName member of the WIN32_FIND_DATA structure. You'll probably find
it really is a directory name.

--
Mike


From: LondonLad on
Hi Mike
Yes I will be the first to admit that i do not have any knowledge on bit
operations but so far this has not stopped me from getting useful code to
work to my requirements. I have read the article that Kevin Provance
suggested at that has not helped me to understand the problem I have.
As you said I had tried the prints to the intermediate window and I get this
result

? (17 and 16) <> 16 Result False
? (16 and 16) <> 16 Result False
is this the correct answer? it seem from what you said it is. OK

You said to look at cFileName which I have and this is a Folder Name and one
of the many that should be checked for Date Created.

Can you help further please?


"MikeD" wrote:

>
>
> "LondonLad" <LondonLad(a)discussions.microsoft.com> wrote in message
> news:7D3A36E3-8722-494B-91D2-6E1A725EEB5D(a)microsoft.com...
> > I am using Randy Birch's CopyFileEx: Create a File Backup App
> >
> > Option Explicit
> > Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10
> >
> > I am stuck as I cannot see why this line of code does not work:-
> >
> > 1. When they are equal
> > 2. When they are not equal
> >
> > I am getting the same result nothing within the if statement is being
> > called
> > whether they are equal or not.
> >
> > 'if the object is not a folder..
> > If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <>
> > FILE_ATTRIBUTE_DIRECTORY Then
> >
> > other code
> >
> > end if
>
> That code is fine.
>
> >
> > When the WFDSource.dwFileAttributes is not a folder its value = 17 and
> > when
> > it is a folder its value = 16
>
> Here's where you're mistaken. If dwFileAttributes has a value of 17, then it
> IS a directory that also has the read-only attribute. The constant for this
> attribute is:
>
> Public Const FILE_ATTRIBUTE_READONLY = &H1
>
> In decimal form, the values are 16 (for directory) and 1 (for read-only).
> Added together, it means that BOTH attributes are present. Try this in the
> Immediate window:
>
> ? 17 and 16
>
> This will print 16 into the immediate window. For a little bit closer
> representation of your code above, try this in the immediate window:
>
> ? (17 and 16) <> 16
>
> Note that it prints False.
>
> The problem doesn't appear to be with the code. Verify what you have for
> the cFileName member of the WIN32_FIND_DATA structure. You'll probably find
> it really is a directory name.
>
> --
> Mike
>
>
> .
>
From: Henning on

"LondonLad" <LondonLad(a)discussions.microsoft.com> skrev i meddelandet
news:0AD8E3F1-3320-45E1-9142-1CFDCF615D9B(a)microsoft.com...
> Hi Mike
> Yes I will be the first to admit that i do not have any knowledge on bit
> operations but so far this has not stopped me from getting useful code to
> work to my requirements. I have read the article that Kevin Provance
> suggested at that has not helped me to understand the problem I have.
> As you said I had tried the prints to the intermediate window and I get
> this
> result
>
> ? (17 and 16) <> 16 Result False

17 and 16 equals 16, so 16 not equal to 16 is False because they *are*
equal.

> ? (16 and 16) <> 16 Result False

Same thing here 16 <> 16 is False.

If the thread starts bottomposting, plz continue that, to make it readable.

/Henning

> is this the correct answer? it seem from what you said it is. OK
>
> You said to look at cFileName which I have and this is a Folder Name and
> one
> of the many that should be checked for Date Created.
>
> Can you help further please?
>
>
> "MikeD" wrote:
>
>>
>>
>> "LondonLad" <LondonLad(a)discussions.microsoft.com> wrote in message
>> news:7D3A36E3-8722-494B-91D2-6E1A725EEB5D(a)microsoft.com...
>> > I am using Randy Birch's CopyFileEx: Create a File Backup App
>> >
>> > Option Explicit
>> > Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10
>> >
>> > I am stuck as I cannot see why this line of code does not work:-
>> >
>> > 1. When they are equal
>> > 2. When they are not equal
>> >
>> > I am getting the same result nothing within the if statement is being
>> > called
>> > whether they are equal or not.
>> >
>> > 'if the object is not a folder..
>> > If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <>
>> > FILE_ATTRIBUTE_DIRECTORY Then
>> >
>> > other code
>> >
>> > end if
>>
>> That code is fine.
>>
>> >
>> > When the WFDSource.dwFileAttributes is not a folder its value = 17 and
>> > when
>> > it is a folder its value = 16
>>
>> Here's where you're mistaken. If dwFileAttributes has a value of 17, then
>> it
>> IS a directory that also has the read-only attribute. The constant for
>> this
>> attribute is:
>>
>> Public Const FILE_ATTRIBUTE_READONLY = &H1
>>
>> In decimal form, the values are 16 (for directory) and 1 (for read-only).
>> Added together, it means that BOTH attributes are present. Try this in
>> the
>> Immediate window:
>>
>> ? 17 and 16
>>
>> This will print 16 into the immediate window. For a little bit closer
>> representation of your code above, try this in the immediate window:
>>
>> ? (17 and 16) <> 16
>>
>> Note that it prints False.
>>
>> The problem doesn't appear to be with the code. Verify what you have for
>> the cFileName member of the WIN32_FIND_DATA structure. You'll probably
>> find
>> it really is a directory name.
>>
>> --
>> Mike
>>
>>
>> .
>>