<%
Set fs = Server.CreateObject("Scripting.FileSystemObject")
' Create new folder
if fs.FolderExists("C:\Test2") = false then
fs.CreateFolder "C:\Test2"
end if
' Copy files
Set SourceFolder = fs.GetFolder("C:\Test1")
Set SourceFiles = SourceFolder.files
if SourceFiles.Count > 0 then
fs.CopyFile "C:\Test1\*.*", "C:\Test2"
end if
Set SourceFiles = nothing
Set SourceFolder = nothing
' Show files name
Set TargetFolder = fs.GetFolder("C:\Test2")
for each x in TargetFolder.files
response.write x.Name & "<br>"
next
Set TargetFolder = nothing
' Delete jpg files
fs.DeleteFile("C:\Test2\*.jpg")
Set fs = nothing
%>
Set fs = Server.CreateObject("Scripting.FileSystemObject")
' Create new folder
if fs.FolderExists("C:\Test2") = false then
fs.CreateFolder "C:\Test2"
end if
' Copy files
Set SourceFolder = fs.GetFolder("C:\Test1")
Set SourceFiles = SourceFolder.files
if SourceFiles.Count > 0 then
fs.CopyFile "C:\Test1\*.*", "C:\Test2"
end if
Set SourceFiles = nothing
Set SourceFolder = nothing
' Show files name
Set TargetFolder = fs.GetFolder("C:\Test2")
for each x in TargetFolder.files
response.write x.Name & "<br>"
next
Set TargetFolder = nothing
' Delete jpg files
fs.DeleteFile("C:\Test2\*.jpg")
Set fs = nothing
%>
參考 W3CSchools