Dir -> Error 70 - Permission Denied

Dir -> Error 70 - Permission Denied

Anonymous
Not applicable
478 Views
4 Replies
Message 1 of 5

Dir -> Error 70 - Permission Denied

Anonymous
Not applicable
Anyone seen this before? I'm sure someone else has. Apparently Dir doesn't
let go of the folder it searches until it finds the last match, which is not
a problem using exact matches or even single character wildcards, but can be
using multiple character wildcards. See the attached test sub. Hopefully
this will prevent someone else headaches down the road. I'm using VBA.

--
James Allen
Malicoat-Winslow Engineers, P.C.
Columbia, MO
0 Likes
479 Views
4 Replies
Replies (4)
Message 2 of 5

arcticad
Advisor
Advisor
'This has always bothered me.
'Make a folder with files names 1.txt 2.txt .... 6.txt

Function dirit()
Dim Str, msg, v1, v2, v3
fPath = "c:\count"
v1 = Dir(fPath & "\*")
v2 = Dir
Debug.Print
v3 = Dir
MsgBox v1 & v2 & v3
End Function

'The result is 1.txt3.txt6.txt
'Dir is iterating the next item for everyline of code

---------------------------

I use this now to do searches.
You can change the search paths

Public Declare Function SearchPath Lib "kernel32" _
Alias "SearchPathA" _
(ByVal lpPath As String, _
ByVal lpFileName As String, _
ByVal lpExtension As String, _
ByVal nBufferLength As Long, _
ByVal lpBuffer As String, _
ByVal lpFilePart As String) As Long

Public Function FindFile(FileName As String) As String

Dim sPath As String, retVal As Long
Dim lpBuffer As String, nCount As Integer

nCount = 255
lpBuffer = Space(nCount)

sPath = AcadApplication.path & ";" & AcadApplication.Preferences.files.SupportPath
retVal = SearchPath(sPath, FileName, 0, nCount, lpBuffer, lpFilePart)
If retVal Then FindFile = left(lpBuffer, retVal)

End Function
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 5

Anonymous
Not applicable
Have you tested your Findfile function?
Sorry, but I think it stinks, try yourself
Tested on A2005-2007

~'J'~
0 Likes
Message 4 of 5

arcticad
Advisor
Advisor
It works perfectly fine for me.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 5 of 5

Anonymous
Not applicable
Hello articad
Sorry if so
This is a strange matter, okay, forget about
Btw, API function SearchTreeForFile will be
work good I think

Regards,

~'J'~
0 Likes