我正在使用以下代码尝试写出服务器根目录下的所有文件...
这是我到目前为止的代码......
<%@ Import Namespace="System.IO" %>
<script language="vb" runat="server" explicit="true" strict="true">
Dim position As Integer
Public Sub GetFiles(ByVal path As String)
If File.Exists(path) Then
' This path is a file
ProcessFile(path)
ElseIf Directory.Exists(path) Then
' This path is a directory
ProcessDirectory(path)
End If
End Sub
' Process all files in the directory passed in, recurse on any directories
' that are found, and process the files they contain.
Public Sub ProcessDirectory(ByVal targetDirectory As String)
' Process the list of files found in the directory.
Dim fileEntries As String() = Directory.GetFiles(targetDirectory)
For Each fileName As String In fileEntries
ProcessFile(fileName)
Next
' Recurse into subdirectories of this directory.
Dim subdirectoryEntries As String() = Directory.GetDirectories(targetDirectory)
For Each subdirectory As String In subdirectoryEntries
ProcessDirectory(subdirectory)
Next
End Sub
' Insert logic for processing found files here.
Public Sub ProcessFile(ByVal path As String)
Dim fi As New FileInfo(path)
Response.Write("File Number " + position.ToString() + ". Path: " + path + " <br />")
position += 1
End Sub
GetFiles("\images\")
</script>
我在以下代码行中收到声明预期编译错误:
GetFiles("\images\")
我有什么需要在这里声明的吗?我只是扯掉我的头发并在这个上秃顶...... arggg!