DeleteFile(filespec) with relative path?
Hello everyone,
I have an access db with a table containing relative links to files. I need to use the file system object to delete the file from a directory and then delete the record from my db.
My hosting environment is shared Win2K Pro. Do I have to have the absolute path to the file I want to delete? or can I use the relative path. I keep getting "file not found errors"
Here is a sample of the code I'm using...
<%
scid = BestLong(request.QueryString("scid"))
dlid = BestLong(request.QueryString("dlid"))
sc_name = DLookup("SC","SC","SCID=" & scid) 'gets name of sub category
recordcount = DCount("*","SC","CCID=3") 'counts all records in db
edit = request.QueryString("edit") = "yes"
delete = request.QueryString("delete") = "yes"
confirm = request.QueryString("confirm") = "yes"
if confirm and scid > 0 and dlid > 0 then
filelink = DLookup("DLLink","Downloads","DLID=" & dlid) 'gets relative path stored in table Downloads
filename = Right(filelink, Len(filelink) - InStrRev(filelink, "/", -1, 1))
filespec = "../gl/admin/documents/" & filename
dim objFSO
set objFSO = server.CreateObject("Scripting.FileSystemObject")
response.Write(filespec)
objFSO.DeleteFile(filespec)
cmd = "delete from SCDownloads where DLID = " & dlid & ""
on error resume next
DoSQL MM_ConGL_STRING, cmd
on error goto 0
cmd = "delete from Downloads where DLID = " & dlid & ""
on error resume next
DoSQL MM_ConGL_STRING, cmd
on error goto 0
set objFSO = nothing
response.Redirect "dsc_dld.asp?scid=" & scid
end if
%>
Any ideas why that is returning a file not found error? Any insight appreciated.
Thanks,
Brandon
bT
|