In a ASP.NET web application, I am using the following code to move uploaded files to an archive folder. When the following code executes, I receive the following error message: "Cannot create a file when that file already exists."
The code listed below is failing on the file.MoveTo call.
What is causing this error?
NOTE: Five files exists in the UploadedXML folder. The Uploaded\Archive folder does not contain any files.
'Move Uploaded file to Archive Folder.
Dim di As System.IO.DirectoryInfo = New DirectoryInfo(Server.MapPath("UploadedXML"))
For Each file As FileInfo In di.GetFiles
file.MoveTo(Server.MapPath("UploadedXML/Archive"))
Next