In a directory I have files like:
The first part of the file name is the user ID plus the extension.
Everytime the user uploads a file I want to delete the old file.
The new file could have different extension than the previous one.
So lets say user 872 wants to upload a new file 872.txt, I want to check the file
and see if a file with userID 872 exists or not. If it exists then delete.
I cant get the if exists part to work.
This is the code I have:
pathToFile2 = Server.mapPath("../../Temp/") & "\" & ID & ".*"
'It looks something like this C:/Temp/872.*
'Delete the old file for this User befor adding the new one
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(pathToFile2) Then
Set fso = Nothing
So above when I take the If Exist part out it works. But when the user has no files it fails