Creating and Deleting a File Using Code
Posted on 2007-08-02
I'm using the following code in my app to create a 'lock' file, copy an existing file, then delete the 'lock' file again:
System.IO.File.Create(AccessDataPath & "Backup.lck")
Dim myFilename As String = Now.Hour & "-" & Now.Minute & "-" & Now.Second & " Backup"
System.IO.File.Copy(AccessDataPath & "Central.mdb", AccessDataPath & myFilename & ".ybs")
System.IO.File.Delete(AccessDataPath & "Backup.lck")
It creates the file OK and copies the other file but when it tries to delete the created 'lock' file it says the file is currently in use. Can someone tell me how to get around this problem.