hi,
I have this code to delete a file from a folder
set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile("F:\Inetpub\WWWRoot\upfiles\" & getname, true)
but it gives an error saying
Microsoft VBScript compilation error '800a0414'
Cannot use parentheses when calling a Sub
any idea
todd
Was this answer helpful ?
Yes No
lewy,
tried ur code it still gives the same error
Microsoft VBScript compilation error '800a0414'
Cannot use parentheses when calling a Sub
todd
Was this answer helpful ?
Yes No
add the bolded lines and make sure it contains a file name
Code:
strFileNameAndPath = "F:\Inetpub\WWWRoot\upfiles\" & getname
response.Write(strFileNameAndPath)
response.End
Was this answer helpful ?
Yes No
lewy,
when i tried this code
Code:
If fs.FileExists(strFileNameAndPath) Then
fs.DeleteFile(Server.MapPath("F:\Inetpub\WWWRoot\upfiles\" & getname))
End If
i didnt get any errors but it didnt deleted the file in the folder
any idea
todd
Was this answer helpful ?
Yes No
Quote:
| Originally Posted by todd2006 lewy,
when i tried this code
Code:
If fs.FileExists(strFileNameAndPath) Then
fs.DeleteFile(Server.MapPath("F:\Inetpub\WWWRoot\upfiles\" & getname))
End If
i didnt get any errors but it didnt deleted the file in the folder
any idea
todd |
Why in the hell would you check the variable name if the file exists and then use an absolute path? That makes no sense.
Was this answer helpful ?
Yes No
response.Write that line out and you will see why it didn't delete anything
Code:
response.Write(Server.MapPath("F:\Inetpub\WWWRoot\upfiles\" & getname))
Was this answer helpful ?
Yes No
hi,
when i tried it like this i get this error
The Path parameter for the MapPath method must be a virtual path. A physical path was used.
any idea
todd
set fs = CreateObject("Scripting.FileSystemObject")
getname = Server.MapPath("F:\Inetpub\WWWRoot\upfiles\" & getname1)
Response.write getname
If fs.FileExists(getname) Then
Response.write "there"
fs.DeleteFile(getname)
End If
Was this answer helpful ?
Yes No
Quote:
| Originally Posted by todd2006 hi,
when i tried it like this i get this error
The Path parameter for the MapPath method must be a virtual path. A physical path was used.
any idea
todd
set fs = CreateObject("Scripting.FileSystemObject")
getname = Server.MapPath("F:\Inetpub\WWWRoot\upfiles\" & getname1)
Response.write getname
If fs.FileExists(getname) Then
Response.write "there"
fs.DeleteFile(getname)
End If |
Hmm, probably because Server.MapPath() FINDS the absolute path. You need to give it a relative path, more than likely something such as:
Code:
getName = Server.MapPath("\upfiles\" & getName1)
response.write getName
response.end
That SHOULD return the following:
Code:
F:\Inetpub\WWWRoot\upfiles\myGetNameValue
Was this answer helpful ?
Yes No
hi,
i even tried it like this
Code:
getname = Server.MapPath("/upfiles/" & getname1)
If IsFileExists(getname) = True Then
Response.Write "File exists"
objFSO.DeleteFile(getname)
Else
Response.Write "File does not exists"
End If
Function IsFileExists(byVal FileName)
If getname = "" Then
IsFileExists = False
Exit Function
End If
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists( getname ) = True Then
IsFileExists = True
Else
IsFileExists = False
End If
Set objFSO = Nothing
End Function
but it doesnt delete the old file
any idea
todd
Was this answer helpful ?
Yes No