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(Acce ssDataPath & "Backup.lck")
Dim myFilename As String = Now.Hour & "-" & Now.Minute & "-" & Now.Second & " Backup"
System.IO.File.Copy(Access DataPath & "Central.mdb", AccessDataPath & myFilename & ".ybs")
System.IO.File.Delete(Acce ssDataPath & "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
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(Acce
Dim myFilename As String = Now.Hour & "-" & Now.Minute & "-" & Now.Second & " Backup"
System.IO.File.Copy(Access
System.IO.File.Delete(Acce
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See the IO namespace
http://msdn2.microsoft.com/en-us/library/system.io.file.delete(VS.71).aspx
http://msdn2.microsoft.com/en-us/library/system.io.file(VS.71).aspx
vbturbo