I am using aspUpload and I am having an unusual problem. When I run the following code, the single line(after blue comment)works fine but when I replace it with the two lines after the red comment, I get an error saying "The process cannot access the file because it is being used by another process." when the .copyFile command runs. Even when I comment out the .createDirectory line, I still get the error when I try the .copyFile. Any ideas?
Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)
Code:
if inStr(request.serverVariables("CONTENT_TYPE"),"multipart/form-data") > 0 then
dim upload, count, thisServer, fileNum, file
set upload = server.createObject("Persits.Upload")
thisServer = server.mapPath("../uploads/LRT/temp")
count = upload.save(thisServer)
if count = 1 then
'a new file now resides in the temp folder
dim newFile, newFileName
dim oldFilePath
set newFile = upload.files("newFile")
If Not newFile Is Nothing Then
if newFile.ext = ".xls" then
newFileName = "LRT - " & upload.form("leaseNumber") & ".xls"
oldFilePath = server.mapPath("../uploads/LRT/" & newFileName)
if upload.fileExists(oldFilePath) then
[COLOR=red]these next two lines cause a "file in use" error when run[/color]
[b]upload.createDirectory server.mappath("../uploads/LRT") & "/DEL", true
upload.copyFile oldFilePath, replace(oldFilePath, "/LRT/", "/LRT/DEL/"), true[/b]
[COLOR=blue]this line works fine when I run it separately[/color]
[b]upload.copyFile oldFilePath, replace(oldFilePath, "LRT -", "DEL -"), true[/b]
end if
end if
End If
end if
response.end
end if
Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)
