Click to See Complete Forum and Search --> : Scripting.FileSystemObject MoveFile Error - file already exists


bloke
09-04-2003, 09:11 AM
Guys

I'm posting files using a multipart form and ms posting acceptor to a folder on our intranet server. No problem. I then attach them to an email using CDONTS and off they go. Now, I was then deleting them from the folder using fso deletefile and all was fine but I decided that rather than delete them, I would move them to another folder.

I create the subfolder thus:



code:--------------------------------------------------------------------------------

'create a folder especially for this requisition...
Dim filesys, demofolder, folcoll
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofolder = filesys.GetFolder("D:\intranet\uploads\")
Set folcoll = demofolder.SubFolders
folcoll.Add(rs.Fields("requisitionID").Value)

--------------------------------------------------------------------------------


...fine, but then when I try to move the files:


code:--------------------------------------------------------------------------------

'...and move the attachments into it....
dim objfilesys
for intx = lbound(arrX) to ubound(arrX)
Set objfilesys = CreateObject("Scripting.FileSystemObject")


objfilesys.MoveFile Server.MapPath("../uploads/" & arrX(intx)), Server.MapPath("../uploads/" & rs.Fields("requisitionID").Value & "/")
Next

--------------------------------------------------------------------------------


it all goes pear shaped and I get the error:

Microsoft VBScript runtime error '800a003a'

File already exists

Any help would be greatly appreciated as I'm just about fed up of all this web development lark and am contemplating becoming a zoo keeper instead. Or something.

Cheers

bloke
09-04-2003, 09:24 AM
Changing this:

objfilesys.MoveFile Server.MapPath("../uploads/" & arrX(intx)), Server.MapPath("../uploads/" & rs.Fields("requisitionID").Value & "/")

to this:

objfilesys.MoveFile Server.MapPath("../uploads/" & arrX(intx)), "D:\intranet\uploads\" & rs.Fields("requisitionID").Value & "/"

Did the trick. Hope this is useful to someone else.

Cheers