寻找一种非 vb 解决方案来收集本地目录中的文件名并放入 javascript 数组中。该应用程序不是网络绑定的。它只会在本地运行。vb解决方案如下。目前这工作正常,但我需要在文件名集合上走另一条路。在下面的脚本运行之后,我有一些 javascript 可以获取 vars-wood、metal、plastic- 并与它们一起运行。关于获取将在 Firefox 或 chrome 中运行的本地文件名目录的其他脚本解决方案的任何建议?我没有运行本地网络服务器,但考虑到 nodejs-对于我需要的东西似乎有点矫枉过正。这是一个使用 html、css、javascript 和 jquery 的本地网络浏览器应用程序。
<script language="vbscript">
'List Files in a particular Directory
Dim fs2, f2, fs3, f3, fs4, f4, wood, metal, plastic, folderspec2, folderspec3, folderspec4, strFileName2
folderspec2 = ".\wood"
folderspec3 = ".\metal"
folderspec4 = ".\plastic"
Set fs2 = CreateObject("Scripting.FileSystemObject")
Set f2 = fs2.GetFolder(folderspec2)
For Each FileName In f2.files
wood = wood & fileName.name
wood = wood & ","
Next
set f2 = nothing
set fs2 = nothing
Set fs3 = CreateObject("Scripting.FileSystemObject")
Set f3 = fs3.GetFolder(folderspec2)
For Each FileName In f3.files
metal = metal & fileName.name
metal = metal & ","
Next
set f3 = nothing
set fs3 = nothing
Set fs4 = CreateObject("Scripting.FileSystemObject")
Set f4 = fs4.GetFolder(folderspec2)
For Each FileName In f4.files
plastic = plastic & fileName.name
plastic = plastic & ","
Next
set f4 = nothing
set fs4 = nothing
</script>