PDA

Click to See Complete Forum and Search --> : Saving to file, file is locked how to unlock


rressa
Aug 14th, 2000, 03:18 AM
I am using text file saved in common delimintaer format,
I am running an extenal program to save the file (monday.txt which already exists at the time of trying to save it)
One of my data contol acces this file.
then i try to overwrite the existing monday.txt file it tells me file in use)
Pls help

bar
Aug 14th, 2000, 03:50 AM
If the form with your data control is still visible, that means that the file is in use by the data control. Windows won't let you overwrite the file if it is open. One way of closing it is to unload the form with the data control. Otherwise use some other method of accessing the data, which doesn't need the data control.

If you could show some of the code you are using it would be easier to show you the solution.

rressa
Aug 14th, 2000, 06:06 AM
Thanks

ill unload the form

thanks

Mr_Ed
Oct 10th, 2000, 11:01 AM
My application reads a txt file using OPEN / CLOSE. Even after the application is ended, the file is in a state that will not allow the Delete function of Windows Explorer to work. What is returned is this message

"Error Deleting File
Cannot delete tempea: Access is denied
Make sure the disk is not full or write-protected
and that the file is not currently in use."

If I reboot my PC, then I can delete the file with Windows Explorer.

What can I do within my VB program to make this file available for normal use??

Mr_Ed
Oct 10th, 2000, 12:14 PM
I found a chunk of code to test whether a file was open or closed. Put it in at the end of my application and when found the file open, I used the CLOSE #5 to close the file in question. I had called the code chunk a second time to see if the file was open or closed. IT IS STILL OPEN!!

That is why I get the problem in my previous posting.

How can I close the file? Or figure out why it is still OPEN??

bar
Oct 11th, 2000, 02:15 AM
Please post some code, maybe I can help.

Mr_Ed
Oct 11th, 2000, 06:35 AM
Thanks for the offer, but I changed the thread to the correct group... General VB and with some help have found what seems to be a problem. If my opened file is on a local D:\ drive my app works great. If my opened file is on a network drive, then the file remains open even if I use the same close command that works for a local drive.

bar
Oct 11th, 2000, 07:23 AM
That is because the server system on the other machine takes a while to refresh (Up to 20 seconds). You'll find that if you wait a couple of seconds and then test for the open file, it will be closed.

I asume this thread can be closed now.

Mr_Ed
Oct 11th, 2000, 07:52 AM
You are the owner of this thread, as suggested by bar, would you close this thread. Thanks...