Path Not found Error

Rkay

Registered User.
Local time
Tomorrow, 02:19
Joined
Jan 11, 2012
Messages
11
Hi all,
i am trying to get folder size on a network drive and coming up with a Path not found error, please see below code:


Set fso = CreateObject("Scripting.FileSystemObject")
Set fso2 = CreateObject("Scripting.FileSystemObject")
sql = "Select [Server Name] from Table "
set rs = db.openrecordset(sql)

With rs
Do while not .EOF
Set ObjSource = fso.GetFolder(.Fields(0).Value)
For each ObjFolder in ObjSource.SubFolders
'*****i Have tried:
iSize = ObjFolder.Size
'**** and i have tried
iSize = fso2.GetFolder(.Fields(0).Value & "\" & ObjFolder.Name & "\").Size
'**** and i have tried
iSize = fso2.GetFolder(ObjFolder.Name & "\").Size
Next

.MoveNext
Loop
End With
....

It fails on certain folders not all of them...I have checked if the folder exists and its there.
I have also copied the name from vba and tried to open it myself in windows and it opens.
i even can get the size of the folder from windows.


Any help is appreciated
 
Hi mdlueck,
This is only part of the code i got, this is full code:

Dim db As Database
Dim ObjSource As Object
Dim fso As Object
Dim fso2 As Object
Dim rs As Recordset

Dim ssql As String

Dim iSize As Integer


Set db = CurrentDb()
Set fso = CreateObject("Scripting.FileSystemObject")
Set fso2 = CreateObject("Scripting.FileSystemObject")
ssql = "Select [Server] From [ExceptionMapping] WHERE [Use] = Yes"
Set rs = db.OpenRecordset(ssql)

With rs
Do While Not .EOF
Set ObjSource = fso.GetFolder(.Fields(0).Value)
For Each ObjFolder In ObjSource.SubFolders
'*****i Have tried:
iSize = ObjFolder.Size
'**** and i have tried
iSize = fso2.GetFolder(.Fields(0).Value & "\" & ObjFolder.Name & "\").Size
'**** and i have tried
iSize = fso2.GetFolder(ObjFolder.Name & "\").Size
Next
ssql = "Insert Into [tmpException] (Server, Acitivity, ActivityValue_GB, DateCreated)" & _
" Values ('" & .Fields(0).Value & "\" & ObjFolder.Name & "','Size', " & iSize & ", #" & Format(Now, "DD/MM/YYYY") & "#)"
db.Execute (ssql)

Next

For Each Objfile In ObjSource.Files
iSize = 0
iSize = (Objfile.Size / 1024 / 1024 / 1024)
ssql = "Insert Into [tmpException] (Server, Acitivity, ActivityValue_GB, DateCreated)" & _
" Values ('" & .Fields(0).Value & "\" & Replace(Objfile.Name, "'", "''") & "','Size', " & iSize & ", #" & Format(Now, "DD/MM/YYYY") & "#)"
db.Execute (ssql)

Next

.MoveNext
Loop
End With

MsgBox "Exception Monitoring Complete"

Set rs = Nothing
Set ObjSource = Nothing
Set fso = Nothing
Set db = Nothing


End Sub
 

Users who are viewing this thread

Back
Top Bottom