在刪除文件之前,我們會檢測文件是否存在,如果不存在就不需要去刪除了 檢測文件代碼: <HTML> <HEAD><TITLE>文件是否存在示例</TITLE></HEAD> <BODY> <% MySelf=server.mappath("./")&"/test.html" '創建一個FileSystemObject對象事例 Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject") IF MyFileObject.FileExists(MySelf) then Response.write("存在這個文件") Else Response.write("不存在這個文件") END IF %> </BODY> </HTML>