Page 1 of 1 1
Topic Options
#68458 - 2002-07-17 10:51 PM Distinguishing between a file and a directory
kncowans Offline
Getting the hang of it

Registered: 2000-11-11
Posts: 98
Loc: Doncaster, UK
Hello all

I am starting a script to move some directories from one location on our server (Server 2000) to another and have run into a problem.

The following code returns the File Attributes incorrectly.

If I fill in the $Dir variable with a test directory that contains various files and directories the script does not seem to return the correct values.

Any suggestions?

code:
  

Break on

$Dir = "c:\testdir"

$File = Dir("$Dir")

While @Error = 0

$Attrib = GetFileAttr($File) & 16

? "Filename = '$File' Attribute = $Attrib"

?

$File = Dir()

Loop

All I need to do is to be able to distinguish a file from a directory.

I tested this section of the script on Windows XP Home and got the incorrect values.

Thanks in advance
_________________________
Kevin Cowans Senior ICT Technician The Armthorpe School

Top
#68459 - 2002-07-18 04:06 AM Re: Distinguishing between a file and a directory
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
What do you mean by incorrect value?
If GetFileAttrib($file) & 16 evaluates to '0' then it's a file, otherwise it's a directory. What values do you get?
_________________________
There are two types of vessels, submarines and targets.

Top
#68460 - 2002-07-18 04:37 AM Re: Distinguishing between a file and a directory
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
See also, the FAQ

Topic: DIR() Primer
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#68461 - 2002-07-18 07:56 AM Re: Distinguishing between a file and a directory
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
it seems that line:
$Attrib = GetFileAttr($File) & 16

is your reason.
try with this:
$Attrib = GetFileAttr($Dir+"\"+$File) & 16
_________________________
!

download KiXnet

Top
#68462 - 2002-07-18 10:41 AM Re: Distinguishing between a file and a directory
kncowans Offline
Getting the hang of it

Registered: 2000-11-11
Posts: 98
Loc: Doncaster, UK
Hello Lonkero

Thanks for that.

Its amazing how everything becomes clear when someone else points out the problem.

Bye for now

Kevin
_________________________
Kevin Cowans Senior ICT Technician The Armthorpe School

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 277 anonymous users online.
Newest Members
fobrien, NetGnostic, William_h, ali_cat, Quicky76
17787 Registered Users

Generated in 0.053 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org