the following line of code seems to be giving me errors on NT and 2000 computers. Any ideas if this function is supported on those operating systems?
If (GetAttr(DirPath & FileString) And vbDirectory) = vbDirectory Then docodehere
Printable View
the following line of code seems to be giving me errors on NT and 2000 computers. Any ideas if this function is supported on those operating systems?
If (GetAttr(DirPath & FileString) And vbDirectory) = vbDirectory Then docodehere
What are the errors?
Try this:
If (GetAttr(DirPath & FileString) And vbDirectory) Then docodehere
You need to do it this way, the And does a bitwise compare. If it's a directory, the If will test positive. This is for all Windows OS's
No, you don't. Do you know what the And means? It works just as well whether or not you have the " = vbDirectory".Quote:
Originally posted by RyeBread
Try this:
If (GetAttr(DirPath & FileString) And vbDirectory) Then docodehere
You need to do it this way, the And does a bitwise compare. If it's a directory, the If will test positive. This is for all Windows OS's
"(GetAttr(DirPath & FileString) And vbDirectory)" will only ever return zero or vbDirectory. Checking to see if it's the same as vbDirectory (what it was doing before your change) is basically the same as checking to see if it's nonzero (what it does after your change), because it's only nonzero if it's the same as vbDirectory.
Makes sense?
when i run my program on an NT or 2000 box i get the following error.
run-time error '5':
invalid procedure call or argument.
the code runs fine on all 95/98 boxes. i just have the problem on NT and 2000.
the line of code follows.
If (GetAttr(DirPath & FileString) And vbDirectory) = vbDirectory Then
the above line is where the compiler stops. any help would be appreciated.!!!
You may want to check to see if there is a "\" at the end of your path before the filestring. This could cause the error if the directory doesn't exist.
Yeah, it does give an error, but not that error.Quote:
Originally posted by ExcalibursZone
You may want to check to see if there is a "\" at the end of your path before the filestring. This could cause the error if the directory doesn't exist.
techster.
What's in DirPath and FileString? If DirPath begins with "\\", that'll give you the error you're coming up with.
Ah true. I read the statement too fast, thinking he had "(GetAttr(DirPath & FileString) = vbDirectory)", which is a problem.Quote:
Originally posted by Tygur
No, you don't. Do you know what the And means? It works just as well whether or not you have the " = vbDirectory".
"(GetAttr(DirPath & FileString) And vbDirectory)" will only ever return zero or vbDirectory. Checking to see if it's the same as vbDirectory (what it was doing before your change) is basically the same as checking to see if it's nonzero (what it does after your change), because it's only nonzero if it's the same as vbDirectory.
Makes sense?
Yes I know what And does.:rolleyes:
here is the values of the variables
dirpath = "C:\"
filestring = "pagefile.sys"
code in question:
If (GetAttr(DirPath & FileString) And vbDirectory) = vbDirectory Then
again only on NT and 2000 boxes do i get the error. Maybe a rights issue???? im stumped.
I get the same error. It may be due to NT security issues.
I'm running Win2K and windows is on drive D, so I tested it out with DirPath set to "d:\". I got error number 75, "Path/file access error". I'm logged in as an administrator, if it means anything.
I guess you're just going to have to handle the error.
I can handle the error. the problem is that as my agency migrates to windows 2000. my applications will be useless. :(
this is very frustrating. stupid microsoft!!!!! why cant they just have standards!!! well if anyone comes up with a solution please let me know.
has anyone tried this with an api call instead? maybe windows 2000 will like that? who the heck knows.
<sigh> thanks for your help all!
I tested this on several other files (I'm running Win2k) and it worked, just the pagefile.sys gave me issues. I even tested it with other files/directories and it worked. I'd say, just handle this one error the rest should be fine.