我試圖刪除圖像文件,只要用戶單擊鏈接將其刪除。我沒有得到任何錯誤,錯誤號碼爲零。但是,該文件不會被刪除。我可以保存照片文件,但不能刪除它們出於某種原因。這裏是我的代碼:無法使用ASP DeleteFile方法刪除文件
PhotoFile = "\images\networkPartners\" & rs(fieldName)
PhotoPath = Server.MapPath(PhotoFile)
dim ServerFSO
Set ServerFSO=Server.CreateObject("Scripting.FileSystemObject")
if ServerFSO.FileExists(PhotoPath) then
response.Write(PhotoPath)
ServerFSO.DeleteFile(PhotoPath)
end if
set ServerFSO=nothing
當response.write命中時,我確實得到了實際的文件路徑。 (「C:/ web/images」等)一直到文件名。所有大小寫都是正確的,等等。同樣,當我執行「接下來的錯誤恢復」時,根本沒有錯誤,並寫出錯誤號和字符串。
呼喚:
ServerFSO.DeleteFile(PhotoPath, true)
導致錯誤:
Microsoft VBScript compilation error '800a0414'
Cannot use parentheses when calling a Sub
/folder/file_edit.asp, line 32
ServerFSO.DeleteFile(PhotoPath, true)
-------------------------------------^
這看起來像傳統的ASP,而不是ASP.NET - 你確定你標記正確嗎? – Oded 2011-12-21 15:48:05
對不起,這是。我試着把標籤放在「asp」中,但它表示它不存在。沒想到把「經典」放在它面前。 – James 2011-12-21 15:49:12