Object variable or With block variable not set.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object variable or With block variable not set.
Source Error:
Line 25:
Line 26: objFolder = objfso.GetFolder(objstartfolder)
Line 27: wscript.Echo(objFolder.Path)
Line 28: colfiles = objFolder.Files
Line 29:
Here is the code I'm working with:
Expand|Select|Wrap|Line Numbers
- Public Class _Default
- Inherits System.Web.UI.Page
- Dim wscript As Object
- Dim objfile As Object
- Dim objfso As Object
- Dim objFolder As Object
- Dim objstartfolder As Object
- Dim colfiles As Object
- Protected Sub dataButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dataButton.Click
- objfso = CreateObject("Scripting.FileSystemObject")
- objstartfolder = "P:\freddocs\"
- objFolder = objfso.GetFolder(objstartfolder)
- wscript.Echo(objFolder.Path)
- colfiles = objFolder.Files
- For Each objfile In colfiles
- Next
- wscript.Echo(objfile.Name)
- wscript.Echo()
- ShowSubFolders(objfso.GetFolder(objstartfolder))
- End Sub
- Sub ShowSubFolders(ByVal Folder)
- Dim subfolder As Object
- For Each subfolder In Folder.SubFolders
- wscript.Echo(subfolder.Path)
- objFolder = objfso.GetFolder(subfolder.Path)
- colfiles = objFolder.Files
- For Each objfile In colfiles
- wscript.Echo(objfile.Name)
- Next
- wscript.Echo()
- ShowSubFolders(subfolder)
- Next
- End Sub
- End Class
I've read the last person who had this issue, I've done the same thing but if failed.
Thanks,