Link to home
Start Free TrialLog in
Avatar of kiranboi
kiranboi

asked on

Creating and Deleting a File Using Code

Hi All,
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.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of ericwong27
ericwong27
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial