Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Folder.Files code problem.

Status
Not open for further replies.

MarkElls

Programmer
Aug 26, 2003
57
GB
I am trying to write asp pages using vb script to show directory and files on a server so that someone can navigate easily. I know there are simpler and better ways but ASP pages were picked for a reason.

I am getting an error on 'Set Files = Folder.Files' - Any suggestions?








On Error Resume Next

Dim FSO
Dim TestFolder
Dim Folder
Dim FolderText
Dim S
Dim SubFolders
Dim SubFolder
Dim Files
Dim File


TestFolder = "C:\CRS"
Set FSO = CreateObject("Scripting.FileSystemObject")
Folder = FSO.GetFolder(TestFolder)

Set Files = Folder.Files

If Files.Count = 1 Then
S = "There is 1 file"
Else
S = "There are more files"
End If

If Files.Count <> 0 Then
For Each File In Files
S = S & "file - "
Next
End If



Set SubFolders = Folder.SubFolders

If 1 = SubFolders.Count Then
S = S & "There is 1 sub folder"
Else
S = S & "There are " & SubFolders.Count & " sub folders"
End If




Cheers.
Mark.
 
What error are you getting? With On Error Resume Next in your script, how do you know where the error is?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Hello MarkElls,

It is that you need this.
[tt]
[red]set[/red] Folder = FSO.GetFolder(TestFolder)
[/tt]
Besides, if it is on the server, you need server.createobject()?

regards - tsuji
 
Thanks tsuji,

I am not sure about server.createobject I amjust a mere dabbler in this. I have all the pages stored on a windows server that has IIS. I then open up the web page and it normally kind of works. I have done similar for crystal enterprise and was hoping to modify some of the code, re-write other bits.


TomThumbKP,
I had loads of debug code which I trimmed out to make the code readable.

Cheers.
Mark.
 
GetFolder() returns object so:
Code:
[b]Set[/b] Folder  = FSO.GetFolder(TestFolder)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top